coupon discount value in product page

  • Posts: 35
  • Thank you received: 1
7 years 5 months ago #283473

hi , in cart page , i saw the code :

$this->element->coupon->discount_value

i tried to use on show_default.php page but it's not definited.

i wanna put a message on product page like " - 5 % at checkout" or " - 10€ at checkout" , but i need to load coupon value for this product.
i must use only COUPON, not discount
it's possible ?

Please Log in or Create an account to join the conversation.

  • Posts: 83779
  • Thank you received: 13566
  • MODERATOR
7 years 5 months ago #283489

Hi,

The coupon variable in $this->element on the cart page is there because $this->element is the cart object there.
The coupons apply to carts, not products. So it's not possible to have such data on the product page as the coupon is not yet loaded hen you reach the product page.
The coupon is loaded by the cart system when the cart data is loaded.

Now you could always have custom MySQL queries on the product page to load the coupons having restrictions on products/categories and display their value. A developer shouldn't have a problem doing that.

Please Log in or Create an account to join the conversation.

  • Posts: 35
  • Thank you received: 1
7 years 5 months ago #283552

ok ,
and what page is the function that makes the autoload of the coupon?
because surely on that page will make a check on the product added to the cart before loading the coupon.

Please Log in or Create an account to join the conversation.

  • Posts: 83779
  • Thank you received: 13566
  • MODERATOR
7 years 5 months ago #283568

Hi,

There is such thing yes. It's done in the function "getFullCart" of the file administrator/components/com_hikashop/classes/cart.php
There, when the cart is being loaded, the coupon in the cart is loaded together (if it's still valid), and if there isn't one in the cart, the system tries to load the "auto loaded" coupons you've configured.

Please Log in or Create an account to join the conversation.

Time to create page: 0.064 seconds
Powered by Kunena Forum