Home Forums Plugins CURCY – WooCommerce Multi Currency i have a problem in ajax with price

i have a problem in ajax with price

  • Author
    Posts
  • #183218

    Attiah Aly
    Participant

    Hello

    i have used a custom code to display the discount and save value in

    shop, cart , checkout page
    ******************************

    //Display Total Discount @ WooCommerce Cart/Checkout//
    add_action( 'woocommerce_cart_totals_before_order_total', 'bbloomer_show_total_discount_cart_checkout', 9999 );
    add_action( 'woocommerce_review_order_before_order_total', 'bbloomer_show_total_discount_cart_checkout', 9999 );
     
    function bbloomer_show_total_discount_cart_checkout() {
        
       $discount_total = 0;
        
       foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {         
          $product = $values['data'];
          if ( $product->is_on_sale() ) {
             $regular_price = $product->get_regular_price();
             $sale_price = $product->get_sale_price();
             $discount = ( $regular_price - $sale_price ) * $values['quantity'];
             $discount_total += $discount;
          }
       }
                 
        if ( $discount_total > 0 ) {
          echo '<tr class="cart-discount"><th>الخصم والتوفير</th><td data-title="total discount">' . wc_price( $discount_total + WC()->cart->get_discount_total() ) .'</td></tr>';
        }
      }
    

    inside product single page
    **************************

    
    //“You save” for sale price
    add_action('woocommerce_get_price_html', 'add_you_save_text_woocommerce', 100, 2);
    
    function add_you_save_text_woocommerce( $price_html, $product ){
    
    ob_start();
    
        if( !$product->is_type('variable') ) {
    
            $regular_price  = $product->get_regular_price();
    
            $active_price   = $product->get_price();
    
             if( !empty($active_price) && $active_price < $regular_price ) {
    
    $amount_saved = $regular_price - $active_price;
    
    $percentage   = intval( ( ( $regular_price - $active_price ) / $regular_price ) * 100 );
    
    ?>
    
    <br>
    
    <p class="you_save_text_woocommerce">
    
    <b>الخصم والتوفير : <?php echo wp_kses_post( wc_price( $amount_saved ) ) . " (". $percentage."%)"; ?></b>
    
    </p>
    
    <?php        
    
            }
    
    }
    
    return $price_html . ob_get_clean();
    
    }
    

    when using your plugin the custom code text disappeared and duplicate another text
    if your plugin is disabled every things return without problem

    attached to you 2 images
    one is the ideal without problem
    and the other one with problem related to your plugin

    hope i get a replay soon

    Attachments:
    You must be logged in to view attached files.

You must be logged in to see replies to this topic. Click here to login or register