hogava Posted August 5, 2018 Share Posted August 5, 2018 how can i set condition for show promotion box when specific product added in card? now i use this conditon: {if $product.pid == '1'} in: templates/orderforms/standard_cart/viewcart.tpl but now when product with pid 1 added to card, promotion card shown, if you add another product condition not worked. i want if product with 1, 2, 3 or 4 added to card promotion box shown on viewcart. tnx 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 6, 2018 Share Posted August 6, 2018 do you mean that only if the cart contains products with IDs of 1,2,3 or 4, do you want to see the promo box below? your method would work if there was either just one applicable product in the cart, or if the first product was applicable in a cart of multiple products... but if your (1,2,3,4) product was second or third in the art, then it would fail. because $products is an array, you would have to loop through it to determine if there was a 1,2,3,4 product somewhere in the cart. you could write a hook that would hide (using css) the entire promo box if the cart does NOT contain 1,2,3,4 - but because of the way WHMCS wrote the template, it would hide the Estimate Taxes tab too... alternative, you could hide the promo input field, but then the tab would still be visible. another way would be to write a hook to determine if product 1,2,3,4 is in the cart and then pass a variable back to viewcart that you can use in the template to determine whether to show the promo box. it's probably also worth mentioning that a user could still apply a promotion code just be editing the URL - so the removal of this box doesn't prevent them from adding a promotion code to the order, it just makes it more difficult. https://docs.whmcs.com/Promotions#Promotion_Links 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.