Display Coupon/Discount Value in Showcart

  • Posts: 109
  • Thank you received: 5
9 years 11 months ago #184029

-- HikaShop version -- : 2.3.4
-- Joomla version -- : 3.3.6

Hello, there.

Good afternoon!

The cart/showcart view does not display discount value (although the cart modules and checkout/cart have the ability to do so).

In trying to display the coupon value in the cart/showcart.php view, I am trying to do the following:

1) have the ability to add/delete a coupon in this view
2) display a discount/coupon line total in footer

Regarding:

Point 1 - ability to add/delete a coupon in the cart/showcart view, I have included the following code:

<span class="hikashop_checkout_coupon" id="hikashop_checkout_coupon">
	<?php
	if(empty($this->cartVal->cart_coupon)){
		echo JText::_('HIKASHOP_ENTER_COUPON');
		?>
		<input id="hikashop_checkout_coupon_input" type="text" name="coupon" value="" />
	<?php
		echo $this->cart->displayButton(JText::_('ADD'),'refresh',$this->params,hikashop_completeLink(''),'',' onclick="return hikashopCheckCoupon(\'hikashop_checkout_coupon_input\');"');
	}else{
		echo JText::sprintf('HIKASHOP_COUPON_LABEL',@$this->cartVal->cart_coupon);
		global $Itemid;
		$url_itemid='';
		if(!empty($Itemid)){
			$url_itemid='&Itemid='.$Itemid;
		}
		?>
		<a href="<?php echo hikashop_completeLink(''); ?>"  title="<?php echo JText::_('REMOVE_COUPON'); ?>" >
			<img src="<?php echo HIKASHOP_IMAGES . 'delete2.png';?>" alt="<?php echo JText::_('REMOVE_COUPON'); ?>" />
		</a>
	<?php }?>
</span>

However, this above code doesn't add/delete the coupon. Please could you let me know:

a) how to get the add functionality to work? Or at least let me know where I can find/call the hikashopCheckCoupon function?

b) how to get the delete functionality to work? I have copied the above code from checkout/coupon.php and noticed that the delete functionality calls a previous link using hikashop_completeLink. Please let me know what the link is to delete the coupon when called from the cart/showcart.php code.

Point 2 - display a discount/coupon line total in footer
This is simple enough if the value of the coupon is in the $this structure. I noticed that the coupon code is in the structure (under $this->cartVal->cart_coupon) but the value is not there. I am not sure I understand why Hikashop retrieves the coupon code and included it in the structure but not the value.

Please could you let me know how to add the value of the coupon in the $this structure or obtain the value from the cart/showcart.php view?

Thanks very much for your help.

Take care!

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

  • Posts: 13201
  • Thank you received: 2322
9 years 11 months ago #184097

Hi,

To have this working, you have to edit the cart controller in order to add functions to manage the coupons.
View editions will not be enough.

You can see how it's working in the checkout controller, there is many calls to the cart class etc to update coupons.

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

  • Posts: 109
  • Thank you received: 5
9 years 11 months ago #184115

Thanks, Xavier.

At the very least, relating to point 2 which I raised, would you be able to have Hikashop expose the total prices in a consistent manner between the cart/showcart view and the product/cart view? Here is what I mean.

In the view:
a) cart/showcart view:
i) $this->total->prices[0]->price_value shows the total without taking into consideration the discount; and
ii) $this->cartVal->cart_coupon already shows the coupon voucher name (which begs the question why doesn't Hikashop also expose the coupon value either in for example, $this->cartVal->cart_coupon_value or in the $this-total->prices[0] structure (see point b) below)?

b) product/cart view:
i) $this->total->prices[0]->price_value shows the total after the discount and shipping and has $this->total->prices[0]->price_value_without_discount to display the value before the discount is applied.

I am not sure I understand why Hikashop exposes the complete set of values in the product/cart view module but not in the cart/showcart view. Granted, you will say that shipping may not be known until checkout. However, once it is calculated, then cart/showcart view should have information as well.

Thanks.

Take care!

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

  • Posts: 13201
  • Thank you received: 2322
9 years 11 months ago #184127

Hi,

We will see to improve that part. I just added it on my todo list.

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

Time to create page: 0.070 seconds
Powered by Kunena Forum