<pre>
public function install()
{
if (Shop::isFeatureActive()) {
Shop::setContext(Shop::CONTEXT_ALL);
}
return parent::install() &&
$this->registerHook('actionValidateOrder');
}
public function hookActionValidateOrder($params){
$email = $couponCode = '';
$order = $params['order'];
$email = ($order->id_customer == 0 && $order->guest_email) ? $order->guest_email : '';
PrestaShopLogger::addLog("Existing email and coupon found. 11");
// Get the email ID of a guest if applicable
if(empty($email)){
return true;
}
PrestaShopLogger::addLog("Existing email and coupon found. 12");
$cart = new Cart($order->id_cart);
// Get applied cart rules (coupons)
$appliedCartRules = $cart->getCartRules();
foreach ($appliedCartRules as $appliedCartRule) {
$couponCode = $appliedCartRule['code'];
// Use $couponCode as needed
}
// Check if the cart has a voucher (coupon) applied
if (empty($couponCode)){
return true;
}
PrestaShopLogger::addLog("Existing email and coupon found. 14");
if ($this->existsInDatabase($email, $couponCode)){
$errorMessage = 'Coupon already used!';
throw new PrestaShopException($errorMessage);
}else{
PrestaShopLogger::addLog("Existing email and coupon found. 15");
$this->saveToDatabase($email, $couponCode);
}
return true;
}
</pre>
I have this code, other 2 functions for checking and savetoDatabase are also fine. But i am not sure why this function is never called, never create a log. Can someone please help me.