Price FR Peeler

0.0/5
<?php
add_filter( 'woocommerce_get_price_html', 'modify_fr_price_peeler', 2, 2 );
function modify_fr_price_peeler( $price_html, $product ) {
    
    if ( get_site_url() == 'https://reclar.fr' ) {
	
    if ( is_admin() ) return $price_html;
  
    if ( '' === $product->get_price() ) return $price_html;
    
    if (  $product->get_id() == "3836" ) {
		echo "<del style='font-size:18px;color: #6ec1e4;'>€199</del>";
        $price_html = wc_price("159.2");
	}
    
	
    return $price_html;
 
	}
	return $price_html;
}



add_action( 'woocommerce_before_calculate_totals', 'modify_cart_fr_price_peeler', 9999 );
 
function modify_cart_fr_price_peeler( $cart ) {
    if ( get_site_url() == 'https://reclar.fr' ) {
	if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return;
	$product_id = "3836";
  
   	$product_cart_id = WC()->cart->generate_cart_id( $product_id );
   	$in_cart = WC()->cart->find_product_in_cart( $product_cart_id );
 
    if ( did_action( 'woocommerce_before_calculate_totals' ) >= 2 ) return;
 	if ( $in_cart ) {
		if ( get_site_url() == 'https://reclar.fr' ) {
    	foreach ( $cart->get_cart() as $cart_item_key => $cart_item ) {
			if (  $cart_item['product_id'] ==  3836 ) {
        	$product = $cart_item['data'];
        	$price = "159.2";
        	$cart_item['data']->set_price( $price );
			}
    	}
		}
	}
	}
}

Comments and reviews

{{ reviewsTotal }} Review
{{ reviewsTotal }} Reviews
{{ options.labels.newReviewButton }}
{{ userData.canReview.message }}

Description

This snippet was fetched automatically from WPDistro.cz projects.

Author

Tags

This snippet is untagged