Jump to content

Display available voucher on product.tpl


acateon

Recommended Posts

Does anyone have any ideas of how to display available vouchers on product.tpl?

To be more specific, only show vouchers that are available for this specific product or the category its in.

 

I'm thinking something of the line of:

{if $voucherAvailable}

{foreach from=$displayVouchers item=voucher}

<p>Take use of this voucher and save {$voucherValue} - {$voucherCode}</p>

{/foreach}

{/if}

 

The reason for this is that I don't want to show the reduced price unless you visit the product page.

 

Would love some help with this, thanks in advance!

 

Edit: I'm using PS 1.4.10.0

Edited by acateon (see edit history)
Link to comment
Share on other sites

Hi.

 

You can a have a look at how the cart is displaying the vouchers.

 

 

Regards.

 

Robin.

 

The CartExpert Team

 

Hey! Thanks for your reply!

 

The variables in shopping-cart.tpl are not applicable in product.tpl, I guess I need to modify productcontroller...?

The only one that seems to work is {if $voucherAllowed} but the foreach loop with $displayVouchers does nothing.

 

Edit: neither does {$voucher.name} - {$voucher.description}

Edited by acateon (see edit history)
Link to comment
Share on other sites

Hi.

 

Of course it will not, you need to assign a value to the variables.

 

CartRule::getCustomerCartRules function will give you an idea on how to do it.

 

Also you can check ParentOrderController to see how the return value of the function is processed.

 

Regards.

Robin.

The CartExpert Team

Link to comment
Share on other sites

  • 2 weeks later...

Thanks for pointing me in the right direction. I´ve tried back and forth with really no success at all. Guess I'm in quite a bit over my head.

 

I've tried adding the following to the product controller:

 

$discounts = self::$cart->getDiscounts(); 
$discountName = $cart->{Tools::getValue ('discount_name')};
//$discount = new Discount((int)($this->product->id),(Discount::getIdByName($discountName)));
self::$smarty->assign(array(
 
'discount_name' => Tools::safeOutput($discounts),
'displayVouchers' => Discount::getVouchersToCartDisplay((int)(self::$cookie->id_lang)),
));

Just scrap at the moment, but could anyone give me some tips? As of now I have no idea really of what I'm doing.

Edited by acateon (see edit history)
Link to comment
Share on other sites

  • 1 year later...
  • 9 months later...
  • 5 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...