-- HikaShop version -- : 2.3.1
-- Joomla version -- : 2.5.2
-- PHP version -- : 5
Hi,
I am trying to write a plugin that executes when a coupon is deleted from the frontend of the website by a customer. What i need it to do, is remove a particular item from the basket when a certain coupon is deleted. I have added what i have coded so far below. I cannot even get an exit() statement alone to execute in the onAfterDiscountDelete(&$elements) function. The onAfterDiscountDelete(&$elements) function doesn't appear to execute even when a coupon is deleted from the frontend of the website. I have written numerous plugins for hikashop now and they have all worked so far (except for this one)...
So i need to know:
Why my plugin is not executing;
What code i need to delete an item from the basket;
My plugin is installed and it is published so that is not the issue here. I have stored my plugin in:-
/plugins/hikashop/discount/
and that folder contains the following files:-
discount.php
discount.xml
index.html
The code below is contained within:-
/plugins/hikashop/discount/discount.php
<?php
defined('_JEXEC') or die('Restricted access');
?><?php
class plgHikashopDiscount extends JPlugin {
function plgHikashopDiscount(&$subject, $config) {
parent::__construct($subject, $config);
}
function onAfterDiscountDelete(&$elements) { if(!@include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')){ return false; }
$cartClass = hikashop_get('class.cart');
$cart = $cartClass->loadFullCart();
$numberOfProductsInCart = sizeof($cart->products);
for($i=0; $i<$numberOfProductsInCart; $i++) {
if($cart->products[$i] == 120) {
//I need some code to remove this item from the basket - but what code will achieve that?
}
}
}
}
?>
Thanks in advance guys!