Cart notification override

  • Posts: 366
  • Thank you received: 19
  • Hikashop Business
2 days 21 hours ago #367583

-- HikaShop version -- : 5.1.6

I am using the cart notification plugin in popup mode. I would like to add a notification about a free purchase in the popup (vex). In which file can I do this?
For the cart module I used the code

<!-- Buy x for free shipping -->
<?php
if($this->element->cart_type == 'cart') {
	$free_shipping_threshold = 35.00;

	$current_total = 0;
	if (isset($this->total->prices[0]->price_value_without_shipping_with_tax)) {
		$current_total = $this->total->prices[0]->price_value_without_shipping_with_tax;
	}

	$remaining = $free_shipping_threshold - $current_total;

	$has_free_shipping_coupon = false;
	if (!empty($this->element->coupon) && isset($this->shipping_price) && (float)$this->shipping_price === 0.0) {
		$has_free_shipping_coupon = true;
	}

	if ($remaining > 0 && !$has_free_shipping_coupon) {
		$remaining_formatted = number_format($remaining, 2, ',', '');
		$progress = min(100, round(($current_total / $free_shipping_threshold) * 100));

		echo '<div class="hikashop_free_shipping_notice">';
		echo '<div class="hikashop_free_shipping_text">' . JText::sprintf('DO_BREZPLACNE_DOSTAVE', $remaining_formatted) . '</div>';
		echo '<div class="hikashop_free_shipping_progress">';
		echo '<div class="hikashop_free_shipping_progress_bar" style="width: ' . $progress . '%;"></div>';
		echo '</div>';
		echo '</div>';
	}
}
?>

Deluje odlično. Rad bi enako funkcionalnost dodal tudi v popup.

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

  • Posts: 83937
  • Thank you received: 13600
  • MODERATOR
2 days 16 hours ago #367587

Hi,

You want to create a small plugin implementing the onGetCartProductsInfo event:
www.hikashop.com/support/documentation/6...nGetCartProductsInfo
In it, you have access to

$ret['messages']
which is an array of messages to be sent to the JavaScript.
The JavaScript of the cart notification plugin will then display the first message of that array in the popup.
So, you can append your HTML to that first message in the array and it will appear in the popup automatically.

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

Time to create page: 0.055 seconds
Powered by Kunena Forum