Beispiel #1
0
 public function view()
 {
     if (StoreCart::getTotalItemsInCart() == 0) {
         $this->redirect("/cart/");
     }
     $this->set('customer', $this->customer);
     $this->set('form', Core::make("helper/form"));
     $this->set("states", Core::make('helper/lists/states_provinces')->getStates());
     $billingCountryArray = StoreCheckoutUtility::getCountryOptions();
     $shippingCountryArray = StoreCheckoutUtility::getCountryOptions('shipping');
     $this->set("billingCountries", $billingCountryArray['countries']);
     $this->set("shippingCountries", $shippingCountryArray['countries']);
     $this->set("defaultBillingCountry", $billingCountryArray['defaultCountry']);
     $this->set("defaultShippingCountry", $shippingCountryArray['defaultCountry']);
     $totals = StoreCalculator::getTotals();
     $this->set('subtotal', $totals['subTotal']);
     $this->set('taxes', $totals['taxes']);
     $this->set('taxtotal', $totals['taxTotal']);
     $this->set('shippingtotal', $totals['shippingTotal']);
     $this->set('total', $totals['total']);
     $this->set('shippingEnabled', StoreCart::isShippable());
     $this->getFooterAssets();
     $enabledMethods = StorePaymentMethod::getEnabledMethods();
     $availableMethods = array();
     foreach ($enabledMethods as $em) {
         $emmc = $em->getMethodController();
         if ($totals['total'] >= $emmc->getPaymentMinimum() && $totals['total'] <= $emmc->getPaymentMaximum()) {
             $availableMethods[] = $em;
         }
     }
     $this->set("enabledPaymentMethods", $availableMethods);
 }
 public function redirectForm()
 {
     $customer = new StoreCustomer();
     $totals = StoreCalculator::getTotals();
     $paypalEmail = Config::get('vividstore.paypalEmail');
     $order = StoreOrder::getByID(Session::get('orderID'));
     $this->set('paypalEmail', $paypalEmail);
     $this->set('siteName', Config::get('concrete.site'));
     $this->set('customer', $customer);
     $this->set('total', $order->getTotal());
     $this->set('notifyURL', URL::to('/checkout/paypalresponse'));
     $this->set('orderID', $order->getOrderID());
     $this->set('returnURL', URL::to('/checkout/complete'));
     $currencyCode = Config::get('vividstore.paypalCurrency');
     if (!$currencyCode) {
         $currencyCode = "USD";
     }
     $this->set('currencyCode', $currencyCode);
 }
Beispiel #3
0
 /**
  * @param array $data
  * @param StorePaymentMethod $pm
  * @param string $transactionReference
  * @param boolean $status
  * @return Order
  */
 public function add($data, $pm, $transactionReference = '', $status = null)
 {
     $customer = new StoreCustomer();
     $now = new \DateTime();
     $smName = StoreShippingMethod::getActiveShippingMethodName();
     $shippingTotal = StoreCalculator::getShippingTotal();
     $taxes = StoreTax::getConcatenatedTaxStrings();
     $totals = StoreCalculator::getTotals();
     $total = $totals['total'];
     $pmName = $pm->getPaymentMethodName();
     $order = new Order();
     $order->setCustomerID($customer->getUserID());
     $order->setOrderDate($now);
     $order->setPaymentMethodName($pmName);
     $order->setShippingMethodName($smName);
     $order->setShippingTotal($shippingTotal);
     $order->setTaxTotals($taxes['taxTotals']);
     $order->setTaxIncluded($taxes['taxIncludedTotal']);
     $order->setTaxLabels($taxes['taxLabels']);
     $order->setOrderTotal($total);
     $order->save();
     $customer->setLastOrderID($order->getOrderID());
     $order->updateStatus($status);
     $order->addCustomerAddress($customer, $order->isShippable());
     $order->addOrderItems(StoreCart::getCart());
     $order->createNeededAccounts();
     $order->assignFilePermissions();
     if (!$pm->getMethodController()->external) {
         $order->completeOrder($transactionReference);
     }
     return $order;
 }
Beispiel #4
0
 public function view()
 {
     $pkg = Package::getByHandle('vivid_store');
     $customer = new StoreCustomer();
     $this->set('customer', $customer);
     $guestCheckout = Config::get('vividstore.guestCheckout');
     $this->set('guestCheckout', $guestCheckout ? $guestCheckout : 'off');
     $this->set('requiresLogin', StoreCart::requiresLogin());
     if (StoreCart::getTotalItemsInCart() == 0) {
         $this->redirect("/cart/");
     }
     $this->set('form', Core::make("helper/form"));
     $allcountries = Core::make('helper/lists/countries')->getCountries();
     $db = Loader::db();
     $ak = UserAttributeKey::getByHandle('billing_address');
     $row = $db->GetRow('select akHasCustomCountries, akDefaultCountry from atAddressSettings where akID = ?', array($ak->getAttributeKeyID()));
     $defaultBillingCountry = $row['akDefaultCountry'];
     if ($row['akHasCustomCountries'] == 1) {
         $availableBillingCountries = $db->GetCol('select country from atAddressCustomCountries where akID = ?', array($ak->getAttributeKeyID()));
         $billingCountries = array();
         foreach ($availableBillingCountries as $countrycode) {
             $billingCountries[$countrycode] = $allcountries[$countrycode];
         }
     } else {
         $billingCountries = $allcountries;
     }
     $ak = UserAttributeKey::getByHandle('shipping_address');
     $row = $db->GetRow('select akHasCustomCountries, akDefaultCountry from atAddressSettings where akID = ?', array($ak->getAttributeKeyID()));
     $defaultShippingCountry = $row['akDefaultCountry'];
     if ($row['akHasCustomCountries'] == 1) {
         $availableShippingCountries = $db->GetCol('select country from atAddressCustomCountries where akID = ?', array($ak->getAttributeKeyID()));
         $shippingCountries = array();
         foreach ($availableShippingCountries as $countrycode) {
             $shippingCountries[$countrycode] = $allcountries[$countrycode];
         }
     } else {
         $shippingCountries = $allcountries;
     }
     $discountsWithCodesExist = StoreDiscountRule::discountsWithCodesExist();
     $this->set("discountsWithCodesExist", $discountsWithCodesExist);
     $this->set('cart', StoreCart::getCart());
     $this->set('discounts', StoreCart::getDiscounts());
     $this->set('hasCode', StoreCart::hasCode());
     $this->set("billingCountries", $billingCountries);
     $this->set("shippingCountries", $shippingCountries);
     $this->set("defaultBillingCountry", $defaultBillingCountry);
     $this->set("defaultShippingCountry", $defaultShippingCountry);
     $this->set("states", Core::make('helper/lists/states_provinces')->getStates());
     $totals = StoreCalculator::getTotals();
     $this->set('subtotal', $totals['subTotal']);
     $this->set('taxes', $totals['taxes']);
     $this->set('taxtotal', $totals['taxTotal']);
     $this->set('shippingtotal', $totals['shippingTotal']);
     $this->set('total', $totals['total']);
     $this->set('shippingEnabled', StoreCart::isShippable());
     $this->addHeaderItem("\n            <script type=\"text/javascript\">\n                var PRODUCTMODAL = '" . View::url('/productmodal') . "';\n                var CARTURL = '" . View::url('/cart') . "';\n                var CHECKOUTURL = '" . View::url('/checkout') . "';\n            </script>\n        ");
     $this->requireAsset('javascript', 'vivid-store');
     $this->requireAsset('css', 'vivid-store');
     $this->addFooterItem("\n            <script type=\"text/javascript\">\n                \$(function() {\n                    vividStore.loadViaHash();\n                });\n            </script>\n        ");
     $enabledMethods = StorePaymentMethod::getEnabledMethods();
     $availableMethods = array();
     foreach ($enabledMethods as $em) {
         $emmc = $em->getMethodController();
         if ($totals['total'] >= $emmc->getPaymentMinimum() && $totals['total'] <= $emmc->getPaymentMaximum()) {
             $availableMethods[] = $em;
         }
     }
     $this->set("enabledPaymentMethods", $availableMethods);
 }