Jump to content

Hide price in email Only If quantity over 50


wpdev

Recommended Posts

Hi, could you please help me with an issue? 

I want to hide the price for one product in the WooCommerce emails that I send to the clients Only If the quantity of a product is over 50. For all the other items I want the price to be shown. For example, the order has 2 products, one with 30pcs quantity that displays price, and the other with 120pcs quantity but with a text 'some text' instead of the price.

I modified the email-order-items.php, <?PHP echo $order->get_formatted_line_subtotal($item); ?>  But, It's not working. I'm sure is this line but I don't know how to continue and I'm stuck. 

Thank you so much.

Edited by wpdev
Modified information
Link to comment
Share on other sites

If you can get the quantity you could  use a simple if statement.  Something like

<?php echo ($quantity>50)?'Secret':$order->get_formatted_line_subtotal($item);?>

I'm not familiar with WooCommerce so I don't know how to determine $quantity, but if you look at the part of the template that shows the quantity you can probably figure it out.

  • Great Answer 1
Link to comment
Share on other sites

Hi kicken, thank you so so much, it works perfectly! 🙂 you were right, I just had to change the quantity part like this: 

<?php echo ($item['qty']>50)?'Secret':$order->get_formatted_line_subtotal($item);?>

The only issue is that it still sums up the hidden quantity in the subtotal and total of the order. 

Thank you so much for your help!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.