Пример #1
0
 public static function execute(ApplicationAbstract $application)
 {
     $OSCOM_ShoppingCart = Registry::get('ShoppingCart');
     $requested_product = null;
     if (count($_GET) > 2) {
         $requested_product = basename(key(array_slice($_GET, 2, 1, true)));
         if ($requested_product == 'Add') {
             unset($requested_product);
             if (count($_GET) > 3) {
                 $requested_product = basename(key(array_slice($_GET, 3, 1, true)));
             }
         }
     }
     if (isset($requested_product)) {
         if (Product::checkEntry($requested_product)) {
             $OSCOM_Product = new Product($requested_product);
             if ($OSCOM_Product->isTypeActionAllowed('AddToShoppingCart')) {
                 if ($OSCOM_Product->hasVariants()) {
                     if (isset($_POST['variants']) && is_array($_POST['variants']) && !empty($_POST['variants'])) {
                         if ($OSCOM_Product->variantExists($_POST['variants'])) {
                             $OSCOM_ShoppingCart->add($OSCOM_Product->getProductVariantID($_POST['variants']));
                         } else {
                             OSCOM::redirect(OSCOM::getLink(null, 'Products', $OSCOM_Product->getKeyword()));
                         }
                     } else {
                         OSCOM::redirect(OSCOM::getLink(null, 'Products', $OSCOM_Product->getKeyword()));
                     }
                 } else {
                     $OSCOM_ShoppingCart->add($OSCOM_Product->getID());
                 }
             }
         }
     }
     OSCOM::redirect(OSCOM::getLink(null, 'Cart'));
 }
Пример #2
0
 protected function process()
 {
     $OSCOM_ShoppingCart = Registry::get('ShoppingCart');
     $OSCOM_Customer = Registry::get('Customer');
     $OSCOM_Language = Registry::get('Language');
     $OSCOM_Service = Registry::get('Service');
     $OSCOM_Breadcrumb = Registry::get('Breadcrumb');
     $OSCOM_MessageStack = Registry::get('MessageStack');
     // redirect to shopping cart if shopping cart is empty
     if (!$OSCOM_ShoppingCart->hasContents()) {
         osc_redirect(OSCOM::getLink(null, 'Cart'));
     }
     // check for e-mail address
     if (!$OSCOM_Customer->hasEmailAddress()) {
         if (isset($_POST['email']) && strlen(trim($_POST['email'])) >= ACCOUNT_EMAIL_ADDRESS) {
             if (osc_validate_email_address($_POST['email'])) {
                 $OSCOM_Customer->setEmailAddress(trim($_POST['email']));
             } else {
                 $OSCOM_MessageStack->add('Cart', OSCOM::getDef('field_customer_email_address_check_error'));
                 osc_redirect(OSCOM::getLink(null, 'Cart'));
             }
         } else {
             $OSCOM_MessageStack->add('Cart', sprintf(OSCOM::getDef('field_customer_email_address_error'), ACCOUNT_EMAIL_ADDRESS));
             osc_redirect(OSCOM::getLink(null, 'Cart'));
         }
     }
     // check product type perform_order conditions
     foreach ($OSCOM_ShoppingCart->getProducts() as $product) {
         $OSCOM_Product = new Product($product['id']);
         $OSCOM_Product->isTypeActionAllowed('PerformOrder');
     }
     $OSCOM_Language->load('checkout');
     $OSCOM_Language->load('order');
     $this->_page_title = OSCOM::getDef('confirmation_heading');
     if ($OSCOM_Service->isStarted('Breadcrumb')) {
         $OSCOM_Breadcrumb->add(OSCOM::getDef('breadcrumb_checkout_confirmation'), OSCOM::getLink(null, 'Checkout', null, 'SSL'));
     }
     if (isset($_POST['comments']) && isset($_SESSION['comments']) && empty($_POST['comments'])) {
         unset($_SESSION['comments']);
     } elseif (!empty($_POST['comments'])) {
         $_SESSION['comments'] = osc_sanitize_string($_POST['comments']);
     }
     if (DISPLAY_CONDITIONS_ON_CHECKOUT == '1') {
         if (!isset($_POST['conditions']) || $_POST['conditions'] != '1') {
             $OSCOM_MessageStack->add('Checkout', OSCOM::getDef('error_conditions_not_accepted'), 'error');
         }
     }
     if (Registry::exists('Payment') === false) {
         Registry::set('Payment', new Payment());
     }
     if ($OSCOM_ShoppingCart->hasBillingMethod()) {
         $OSCOM_Payment = Registry::get('Payment');
         $OSCOM_Payment->load($OSCOM_ShoppingCart->getBillingMethod('id'));
     }
 }
Пример #3
0
 public function requireCustomerAccount()
 {
     $OSCOM_ShoppingCart = Registry::get('ShoppingCart');
     foreach ($OSCOM_ShoppingCart->getProducts() as $product) {
         $OSCOM_Product = new Product($product['id']);
         if ($OSCOM_Product->isTypeActionAllowed(array('PerformOrder', 'RequireCustomerAccount'), null, false)) {
             return true;
         }
     }
     return false;
 }
Пример #4
0
 public function __construct($module = null)
 {
     $OSCOM_ShoppingCart = Registry::get('ShoppingCart');
     $OSCOM_Database = Registry::get('Database');
     $OSCOM_Language = Registry::get('Language');
     $do_shipping = false;
     foreach ($OSCOM_ShoppingCart->getProducts() as $product) {
         $OSCOM_Product = new Product($product['id']);
         if ($OSCOM_Product->isTypeActionAllowed('apply_shipping_fees')) {
             $do_shipping = true;
             break;
         }
     }
     if ($do_shipping === true) {
         $this->_quotes =& $_SESSION['osC_ShoppingCart_data']['shipping_quotes'];
         $Qmodules = $OSCOM_Database->query('select code from :table_templates_boxes where modules_group = "shipping"');
         $Qmodules->setCache('modules-shipping');
         $Qmodules->execute();
         while ($Qmodules->next()) {
             $this->_modules[] = $Qmodules->value('code');
         }
         $Qmodules->freeResult();
         if (!empty($this->_modules)) {
             if (!empty($module) && in_array(substr($module, 0, strpos($module, '_')), $this->_modules)) {
                 $this->_selected_module = $module;
                 $this->_modules = array(substr($module, 0, strpos($module, '_')));
             }
             $OSCOM_Language->load('modules-shipping');
             foreach ($this->_modules as $module) {
                 $module_class = 'osCommerce\\OM\\Core\\Site\\Shop\\Module\\Shipping\\' . $module;
                 Registry::set('Shipping_' . $module, new $module_class(), true);
                 Registry::get('Shipping_' . $module)->initialize();
             }
             usort($this->_modules, function ($a, $b) {
                 if (Registry::get('Shipping_' . $a)->getSortOrder() == Registry::get('Shipping_' . $b)->getSortOrder()) {
                     return strnatcasecmp(Registry::get('Shipping_' . $a)->getTitle(), Registry::get('Shipping_' . $b)->getTitle());
                 }
                 return Registry::get('Shipping_' . $a)->getSortOrder() < Registry::get('Shipping_' . $b)->getSortOrder() ? -1 : 1;
             });
         }
     }
     if (empty($this->_quotes)) {
         $this->_calculate();
     }
 }