Jump to content

Qamar Zaman

New Members
  • Posts

    2
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Qamar Zaman's Achievements

Newbie

Newbie (1/14)

  • Week One Done Rare
  • First Post Rare
  • Conversation Starter Rare

Recent Badges

0

Reputation

  1. i try to put a single line log in it, but nothing work, seems that its never called. Can someone help find whats wrong. I have checked the documentation already. Nothing works for me.
  2. <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.
×
×
  • Create New...