Ejemplo n.º 1
0
 public function getPackageShippingCost($id_carrier = null, $use_tax = true, Country $default_country = null, $product_list = null, $id_zone = null)
 {
     global $defaultCountry;
     if (!Module::isInstalled('agilesellershipping') or !Module::isInstalled('agilemultipleseller')) {
         return parent::getPackageShippingCost($id_carrier, $use_tax, $default_country, $product_list, $id_zone);
     }
     $order_total = $this->getOrderTotal($use_tax, Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING);
     if ($order_total <= 0 and !(int) self::getNbProducts($this->id)) {
         return 0;
     }
     include_once _PS_ROOT_DIR_ . "/modules/agilemultipleseller/agilemultipleseller.php";
     include_once _PS_ROOT_DIR_ . "/modules/agilesellershipping/SellerShipping.php";
     $sellers = AgileMultipleSeller::getSellersByCart($this->id);
     if (empty($sellers)) {
         return parent::getPackageShippingCost($id_carrier, $use_tax, $default_country, $product_list, $id_zone);
     }
     if (isset($this->id_address_delivery) and $this->id_address_delivery and Customer::customerHasAddress($this->id_customer, $this->id_address_delivery)) {
         $id_zone = Address::getZoneById((int) $this->id_address_delivery);
     } else {
         if (!Validate::isLoadedObject($defaultCountry)) {
             $defaultCountry = new Country(Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT'));
         }
         $id_zone = (int) $defaultCountry->id_zone;
     }
     $shipping_cost = 0;
     foreach ($sellers as $seller) {
         $seller_cost = $this->getOrderShippingCostPerSeller($id_zone, intval($seller['id_seller']), $use_tax);
         $shipping_cost += $seller_cost;
     }
     return $shipping_cost;
 }
Ejemplo n.º 2
0
 public function validateOrder($id_cart, $id_order_state, $amountPaid, $paymentMethod = 'Unknown', $message = NULL, $extraVars = array(), $currency_special = NULL, $dont_touch_amount = false, $secure_key = false, Shop $shop = null)
 {
     @session_start();
     @set_time_limit(120);
     $_SESSION['id_cart_validating'] = (int) $id_cart;
     if (Module::isInstalled('agileprepaidcredit')) {
         require_once _PS_ROOT_DIR_ . "/modules/agileprepaidcredit/agileprepaidcredit.php";
         AgilePrepaidCredit::set_token_payment_processing_marker($id_cart, true);
     }
     if (!Module::isInstalled('agilemultipleseller')) {
         $ret = parent::validateOrder($id_cart, $id_order_state, $amountPaid, $paymentMethod, $message, $extraVars, $currency_special, $dont_touch_amount, $secure_key);
         if (Module::isInstalled('agileprepaidcredit')) {
             AgilePrepaidCredit::adjustOrderForTokens($this->currentOrder);
             if ($this->name == 'agilepaypalparallel' || ($this->name = 'agilepaypaladaptive')) {
                 AgilePrepaidCredit::checkOrderInvoicePayment($this->currentOrder);
             }
         }
         return $ret;
     }
     require_once _PS_ROOT_DIR_ . "/modules/agilemultipleseller/agilemultipleseller.php";
     $paymode = (int) Configuration::get('AGILE_MS_PAYMENT_MODE');
     $sellers = AgileMultipleSeller::getSellersByCart($id_cart);
     if (count($sellers) <= 1) {
         $id_cart_patent = AgileMultipleSeller::get_subcart_parentid($id_cart);
         $ordervalided = parent::validateOrder($id_cart, $id_order_state, $amountPaid, $paymentMethod, $message, $extraVars, $currency_special, $dont_touch_amount, $secure_key);
         $this->updateSellerCommissionRecordType($paymode, $message);
         if ($ordervalided and $id_cart_patent > 0) {
             AgileMultipleSeller::remove_subcart_items_from_maincart($id_cart, $this->currentOrder);
         }
         if (Module::isInstalled('agileprepaidcredit')) {
             AgilePrepaidCredit::adjustOrderForTokens($this->currentOrder);
             if ($this->name == 'agilepaypalparallel' || ($this->name = 'agilepaypaladaptive')) {
                 AgilePrepaidCredit::checkOrderInvoicePayment($this->currentOrder);
             }
         }
         return $ordervalided;
     }
     $cartinfos = AgileMultipleSeller::split_shopping_cart($id_cart, $sellers);
     if (empty($cartinfos)) {
         $ret = parent::validateOrder($id_cart, $id_order_state, $amountPaid, $paymentMethod, $message, $extraVars, $currency_special, $dont_touch_amount, $secure_key);
         $this->updateSellerCommissionRecordType($paymode, $message);
         if (Module::isInstalled('agileprepaidcredit')) {
             AgilePrepaidCredit::adjustOrderForTokens($this->currentOrder);
             if ($this->name == 'agilepaypalparallel' || ($this->name = 'agilepaypaladaptive')) {
                 AgilePrepaidCredit::checkOrderInvoicePayment($this->currentOrder);
             }
         }
         return $ret;
     }
     $ret = true;
     foreach ($cartinfos as $cartinfo) {
         $_SESSION['id_cart_validating'] = (int) $cartinfo['id_cart'];
         $this->context->cart = new Cart(intval($cartinfo['id_cart']));
         $this->context->cart->getPackageList(true);
         $filter = CartRule::FILTER_ACTION_ALL;
         $cache_key = 'Cart::getCartRules' . $cartinfo['id_cart'] . '-' . $filter;
         if (Cache::isStored($cache_key)) {
             Cache::clean($cache_key);
         }
         if (Module::isInstalled('agileprepaidcredit')) {
             AgilePrepaidCredit::set_token_payment_processing_marker($cartinfo['id_cart'], true);
         }
         $ret = $ret and parent::validateOrder($cartinfo['id_cart'], $id_order_state, $cartinfo['amountPaid'], $paymentMethod, $message, $extraVars, $currency_special, $dont_touch_amount, $secure_key);
         $this->updateSellerCommissionRecordType($paymode, $message);
         if ($this->name == 'agilepaypalparallel') {
             $this->updateTxnDetailCartID($message, $this->currentOrder, $cartinfo['id_cart']);
         }
         if (Module::isInstalled('agileprepaidcredit')) {
             AgilePrepaidCredit::adjustOrderForTokens($this->currentOrder);
             if ($this->name == 'agilepaypalparallel' || ($this->name = 'agilepaypaladaptive')) {
                 AgilePrepaidCredit::adjustOrderPaymentAmount($this->currentOrder, $this->name);
                 AgilePrepaidCredit::checkOrderInvoicePayment($this->currentOrder);
             }
         }
     }
     return $ret;
 }
 public function hookAgileExpressCheckout($params)
 {
     global $cookie, $cart, $smarty, $link;
     if (Module::isInstalled('agilemultipleseller')) {
         include_once _PS_ROOT_DIR_ . "/modules/agilemultipleseller/agilemultipleseller.php";
         if (intval(Configuration::get('AGILE_MS_PAYMENT_MODE')) == AgileMultipleSeller::PAYMENT_MODE_BOTH) {
             return;
         }
         if (intval(Configuration::get('AGILE_MS_PAYMENT_MODE')) != AgileMultipleSeller::PAYMENT_MODE_STORE and count(AgileMultipleSeller::getSellersByCart($cart->id)) > 1) {
             return;
         }
     }
     if (!$this->active) {
         return;
     }
     if (intval(Configuration::get('AGILE_PAYPAL_EXPRESS_ENABLED')) != 1) {
         return;
     }
     $cms = new CMS((int) Configuration::get('PS_CONDITIONS_CMS_ID'), (int) $cookie->id_lang);
     $link_conditions = $link->getCMSLink($cms, $cms->link_rewrite, true);
     if (!strpos($link_conditions, '?')) {
         $link_conditions .= '?content_only=1';
     } else {
         $link_conditions .= '&content_only=1';
     }
     $atpage = AgileHelper::getPageName();
     $back = Tools::getValue('back');
     if ($atpage == "order-opc.php") {
         return;
     }
     if ($atpage == "authentication.php") {
         if (strlen($back) < 9) {
             return;
         }
         if (substr($back, 0, 9) != 'order.php') {
             return;
         }
     }
     if ($cart->nbProducts() == 0) {
         return;
     }
     if ($cart->getOrderTotal() <= 0) {
         return;
     }
     $agilepayoal_redirect_url = Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . "modules/agilepaypal/redirect.php";
     $agilepayoal_recurring_url = Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . "modules/agilepaypal/subscribe.php";
     if (version_compare(_PS_VERSION_, '1.5', '>=')) {
         $agilepayoal_redirect_url = Context::getContext()->link->getModuleLink('agilepaypal', 'redirect', array(), true);
         $agilepayoal_recurring_url = Context::getContext()->link->getModuleLink('agilepaypal', 'subscribe', array(), true);
     }
     if (version_compare(_PS_VERSION_, "1.5", ">=")) {
         Context::getContext()->controller->addJqueryPlugin("fancybox");
         Context::getContext()->controller->addCSS(__PS_BASE_URI__ . "css/jquery.fancybox-1.3.4.css");
     } else {
         Tools::addJS(__PS_BASE_URI__ . "js/jquery/jquery.fancybox-1.3.4.js");
         Tools::addCSS(__PS_BASE_URI__ . "css/jquery.fancybox-1.3.4.css");
     }
     $smarty->assign(array('link_conditions' => $link_conditions, 'agilepaypal_dir' => dirname(__FILE__) . '/', 'atpage' => $atpage, 'back' => $back, 'cycle_base' => $this->get_membership_units(), 'hideterms' => intval(Configuration::get('AGILE_PAYPAL_HIDE_TERMS')), 'sl_country' => isset($selectedCountry) ? $selectedCountry : 0, 'sl_state' => isset($selectedState) ? $selectedState : 0, 'sl_carrier' => isset($selectedCarrier) ? $selectedCarrier : 0, 'agilepayoal_redirect_url' => $agilepayoal_redirect_url, 'agilepayoal_recurring_url' => $agilepayoal_recurring_url, 'agilePaypalExpressCheckoutForm' => $this->getCheckoutForm()));
     return $this->display($this->get_module_file(), 'hookexpresscheckout.tpl');
 }