$id_cart = (int) Tools::getValue('cart'); $cart = new Cart($id_cart); $currency = new Currency((int) $cart->id_currency); $token = Tools::encrypt(Tools::getValue('customer')); if (Tools::getValue('token') !== $token || $cart->id_customer != Tools::getValue('customer')) { die(Tools::jsonEncode(array('error' => true, 'type' => 'user', 'value' => '0'))); } $create = true; unset($_POST['cart']); /** * Get Fid'Bag account information **/ $fidbag_user = new FidbagUser($cart->id_customer); $webService = new FidbagWebService(); $fidbag_user->getFidBagUser(); $return = $webService->action('GetImmediateRebateAmount', array('CardNumber' => $fidbag_user->getCardNumber(), 'MerchantCode' => Configuration::get('FIDBAG_MERCHANT_CODE'))); $json_return = Tools::jsonDecode($return->GetImmediateRebateAmountResult); $max_amount = $json_return->ImmediateRebateAmount; if (_PS_VERSION_ >= '1.5') { $context = Context::getContext(); $context->cart = $cart; $context->currency = $currency; } /** * Check for errors **/ $cart_total = $cart->getOrderTotal(); $discounts_total = $cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS); $shipping_total = $cart->getOrderTotal(true, Cart::ONLY_SHIPPING); if ($amount > (double) $json_return->ImmediateRebateAmount) { $value = $max_amount . ' ' . $currency->sign;
public function hookOrderDetailDisplayed($params) { if (!$this->_activeVerification()) { return false; } $fidBagUser = new FidbagUser($params['order']->id_customer); if (!$fidBagUser) { return false; } $smarty = Context::getContext()->smarty; $webService = new FidbagWebService(); $fidBagUser->getFidBagUser(); $return = $webService->action('GetFidBagCardInformations', array('MerchantCode' => Configuration::get('FIDBAG_MERCHANT_CODE'), 'FidCardNumber' => $fidBagUser->getCardNumber())); if ($return != null) { $json_return = Tools::jsonDecode($return->GetFidBagCardInformationsResult); $smarty->assign('fidbag', $json_return); } return $this->display(__FILE__, 'views/templates/hook/order.tpl'); }