Jump to content
Sign in to follow this  
wpdev

Hide price in email Only If quantity over 50

Recommended Posts

Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

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.

Sign in to follow this  

×
×
  • 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.