Repository Forums Support WooCommerce Extended Coupon Features PRO Show price of free item

Topic Resolution: Resolved
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1899
    info49
    Participant

    Hi,

    to show the customer the value of the free product I would like to show the price. In full or strike through like with a regular discount. Possible?

    Thanks!
    Leen

    #1907
    Soft79
    Keymaster

    Hi, you can use these filters for that:

    
    add_filter( 'wjecf_free_cart_item_price', 
      function ( $text, $price_html, $cart_item, $cart_item_key )
      {
        return "<del>" . $price_html . "</del> <strong>" . __('Free!', 'woocommerce') . "</strong>";
      }, 10, 4);
    
    add_filter( 'wjecf_free_cart_item_subtotal', 
      function ( $text, $price_html, $cart_item, $cart_item_key )
      {
        return "<del>" . $price_html . "</del> <strong>" . __('Free!', 'woocommerce') . "</strong>";
      }, 10, 4);
    
    #1912
    info49
    Participant

    Hi,

    get the following error in the first line:

    Parse error: syntax error, unexpected ‘​’ (T_STRING), expecting ‘,’ or ‘)’

    Thanks

    #1913
    info49
    Participant

    Hi,

    error solved (one space to much after the , in the first and eight line)

    But:

    Price is set to 0,00
    I would like to see the price striked thru and after the price Free

    Thanks,

    #1916
    Soft79
    Keymaster

    I see, try this:

    
    add_filter( 'wjecf_free_cart_item_price', 
      function ( $text, $price_html, $cart_item, $cart_item_key )
      {
        $product = new WC_Product( $cart_item['product_id'] );
        
        return "<del>" . wc_price( $product->get_price() ) . "</del> <strong>" . __('Free!', 'woocommerce') . "</strong>";
      }, 10, 4);
    
    add_filter( 'wjecf_free_cart_item_subtotal', 
      function ( $text, $price_html, $cart_item, $cart_item_key )
      {
        $product = new WC_Product( $cart_item['product_id'] );
        
        return "<del>" . wc_price( $product->get_price() * $cart_item['quantity'] ) . "</del> <strong>" . __('Free!', 'woocommerce') . "</strong>";
      }, 10, 4);
    
    

    PS: I don’t think there was a typo in the snippet. Did you copy/paste well?

    #1917
    info49
    Participant

    Perfect! Thanks.

    PS the typo might have been a slip of the typewriter 😉 Didn’t have it this time. Thanks again!

    #17607
    valentin
    Participant

    Hello, how to show this on the Order Detail as well not just on the Cart?

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.