コード例 #1
0
 /**
  * Make sure addresses will be saved without validation errors
  */
 private function _ignoreAddressValidation()
 {
     $this->_quote->getBillingAddress()->setShouldIgnoreValidation(true);
     if (!$this->_quote->getIsVirtual()) {
         $this->_quote->getShippingAddress()->setShouldIgnoreValidation(true);
     }
 }
コード例 #2
0
ファイル: AbstractPayol.php プロジェクト: buttasg/cowgirlk
 /**
  * @param Mage_Sales_Model_Quote $quote
  * @return Mage_Sales_Model_Order
  * @throws Exception
  */
 public function createNewOrder($quote)
 {
     $convert = Mage::getModel('sales/convert_quote');
     if ($quote->isVirtual()) {
         $this->setOrder($convert->addressToOrder($quote->getBillingAddress()));
     } else {
         $this->setOrder($convert->addressToOrder($quote->getShippingAddress()));
     }
     $this->getOrder()->setBillingAddress($convert->addressToOrderAddress($quote->getBillingAddress()));
     if ($quote->getBillingAddress()->getCustomerAddress()) {
         $this->getOrder()->getBillingAddress()->setCustomerAddress($quote->getBillingAddress()->getCustomerAddress());
     }
     if (!$quote->isVirtual()) {
         $this->getOrder()->setShippingAddress($convert->addressToOrderAddress($quote->getShippingAddress()));
         if ($quote->getShippingAddress()->getCustomerAddress()) {
             $this->getOrder()->getShippingAddress()->setCustomerAddress($quote->getShippingAddress()->getCustomerAddress());
         }
     }
     $this->getOrder()->setPayment($convert->paymentToOrderPayment($quote->getPayment()));
     $this->getOrder()->getPayment()->setTransactionId($quote->getPayment()->getTransactionId());
     foreach ($quote->getAllItems() as $item) {
         /** @var Mage_Sales_Model_Order_Item $item */
         $orderItem = $convert->itemToOrderItem($item);
         if ($item->getParentItem()) {
             $orderItem->setParentItem($this->getOrder()->getItemByQuoteItemId($item->getParentItem()->getId()));
         }
         $this->getOrder()->addItem($orderItem);
     }
     $this->getOrder()->setQuote($quote);
     $this->getOrder()->setExtOrderId($quote->getPayment()->getTransactionId());
     $this->getOrder()->setCanSendNewEmailFlag(false);
     $this->_initTransaction($quote);
     return $this->getOrder();
 }
コード例 #3
0
ファイル: Item.php プロジェクト: ReeceCrossland/essua-m2epro
 private function getProductTaxRate()
 {
     /** @var $taxCalculator Mage_Tax_Model_Calculation */
     $taxCalculator = Mage::getSingleton('tax/calculation');
     $request = $taxCalculator->getRateRequest($this->quote->getShippingAddress(), $this->quote->getBillingAddress(), $this->quote->getCustomerTaxClassId(), $this->quote->getStore());
     $request->setProductClassId($this->getProduct()->getTaxClassId());
     return $taxCalculator->getRate($request);
 }
コード例 #4
0
 /**
  * update customer when edit shipping address to paypal
  *
  * @param $accessCode
  */
 public function updateCustomer($accessCode)
 {
     $response = $this->_doRapidAPI('Transaction/' . $accessCode, 'GET');
     if ($response->isSuccess()) {
         $customer = $this->_quote->getCustomer();
         $billingAddress = $this->_quote->getBillingAddress();
         $shippingAddress = $this->_quote->getShippingAddress();
         $trans = $response->getTransactions();
         if (isset($trans[0]['Customer'])) {
             $billing = $trans[0]['Customer'];
             $billingAddress->setFirstname($billing['FirstName'])->setLastName($billing['LastName'])->setCompany($billing['CompanyName'])->setJobDescription($billing['JobDescription'])->setStreet($billing['Street1'])->setStreet2($billing['Street2'])->setCity($billing['City'])->setState($billing['State'])->setPostcode($billing['PostalCode'])->setCountryId(strtoupper($billing['Country']))->setEmail($billing['Email'])->setTelephone($billing['Phone'])->setMobile($billing['Mobile'])->setComments($billing['Comments'])->setFax($billing['Fax'])->setUrl($billing['Url']);
         }
         if (isset($trans[0]['ShippingAddress'])) {
             $shipping = $trans[0]['ShippingAddress'];
             $shippingAddress->setFirstname($shipping['FirstName'])->setLastname($shipping['LastName'])->setStreet($shipping['Street1'])->setStreet2($shipping['Street2'])->setCity($shipping['City'])->setPostcode($shipping['PostalCode'])->setCountryId(strtoupper($shipping['Country']))->setEmail($shipping['Email'])->setFax($shipping['Fax']);
             if ($shipping['State'] && $shipping['Country'] && ($region = Mage::getModel('directory/region')->loadByCode($shipping['State'], $shipping['Country']))) {
                 $shippingAddress->setRegion($region->getName())->setRegionId($region->getId());
             }
             if ($shipping['Phone']) {
                 $shippingAddress->setTelephone($shipping['Phone']);
             }
         }
         $this->_quote->assignCustomerWithAddressChange($customer, $billingAddress, $shippingAddress)->save();
     }
 }
コード例 #5
0
ファイル: Earning.php プロジェクト: kanotest15/cbmagento
 /**
  * collect reward points that customer earned (per each item and address) total
  * 
  * @param Mage_Sales_Model_Quote_Address $address
  * @param Mage_Sales_Model_Quote $quote
  * @return Magestore_RewardPoints_Model_Total_Quote_Point
  */
 public function collect($address, $quote)
 {
     if (!Mage::helper('rewardpoints')->isEnable($quote->getStoreId())) {
         return $this;
     }
     // get points that customer can earned by Rates
     if ($quote->isVirtual()) {
         $address = $quote->getBillingAddress();
     } else {
         $address = $quote->getShippingAddress();
     }
     $baseGrandTotal = $quote->getBaseGrandTotal();
     if (!Mage::getStoreConfigFlag(Magestore_RewardPoints_Helper_Calculation_Earning::XML_PATH_EARNING_BY_SHIPPING, $quote->getStoreId())) {
         $baseGrandTotal -= $address->getBaseShippingAmount();
     }
     if (!Mage::getStoreConfigFlag(Magestore_RewardPoints_Helper_Calculation_Earning::XML_PATH_EARNING_BY_TAX, $quote->getStoreId())) {
         $baseGrandTotal -= $address->getBaseTaxAmount();
     }
     $baseGrandTotal = max(0, $baseGrandTotal);
     $earningPoints = Mage::helper('rewardpoints/calculation_earning')->getRateEarningPoints($baseGrandTotal, $quote->getStoreId());
     if ($earningPoints > 0) {
         $address->setRewardpointsEarn($earningPoints);
     }
     Mage::dispatchEvent('rewardpoints_collect_earning_total_points_before', array('address' => $address));
     // Update earning point for each items
     $this->_updateEarningPoints($address);
     Mage::dispatchEvent('rewardpoints_collect_earning_total_points_after', array('address' => $address));
     return $this;
 }
コード例 #6
0
ファイル: Data.php プロジェクト: aoepeople/aoe_cartapi
 /**
  * @param Mage_Sales_Model_Quote $quote
  *
  * @return array[]
  */
 public function validateQuote(Mage_Sales_Model_Quote $quote)
 {
     $errors = [];
     if (!$quote->isVirtual()) {
         // Copy data from billing address
         if ($quote->getShippingAddress()->getSameAsBilling()) {
             $quote->getShippingAddress()->importCustomerAddress($quote->getBillingAddress()->exportCustomerAddress());
             $quote->getShippingAddress()->setSameAsBilling(1);
         }
         $addressErrors = $this->validateQuoteAddress($quote->getShippingAddress());
         if (!empty($addressErrors)) {
             $errors['shipping_address'] = $addressErrors;
         }
         $method = $quote->getShippingAddress()->getShippingMethod();
         $rate = $quote->getShippingAddress()->getShippingRateByCode($method);
         if (!$method || !$rate) {
             $errors['shipping_method'] = [$this->__('Please specify a valid shipping method.')];
         }
     }
     $addressErrors = $this->validateQuoteAddress($quote->getBillingAddress());
     if (!empty($addressErrors)) {
         $errors['billing_address'] = $addressErrors;
     }
     try {
         if (!$quote->getPayment()->getMethod() || !$quote->getPayment()->getMethodInstance()) {
             $errors['payment'] = [$this->__('Please select a valid payment method.')];
         }
     } catch (Mage_Core_Exception $e) {
         $errors['payment'] = [$this->__('Please select a valid payment method.')];
     }
     return $errors;
 }
コード例 #7
0
ファイル: Cc.php プロジェクト: roshu1980/add-computers
 /**
  * Validates alias for in quote provided addresses
  * @param Mage_Sales_Model_Quote $quote
  * @param Varien_Object $payment
  * @throws Mage_Core_Exception
  */
 protected function validateAlias($quote, $payment)
 {
     $alias = $payment->getAdditionalInformation('alias');
     if (0 < strlen(trim($alias)) && is_numeric($payment->getAdditionalInformation('cvc')) && false === Mage::helper('ops/alias')->isAliasValidForAddresses($quote->getCustomerId(), $alias, $quote->getBillingAddress(), $quote->getShippingAddress(), $quote->getStoreId())) {
         $this->getOnepage()->getCheckout()->setGotoSection('payment');
         Mage::throwException($this->getHelper()->__('Invalid payment information provided!'));
     }
 }
コード例 #8
0
 /**
  * Returns the current customers email adress.
  * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $object
  * @return string the customers email adress
  */
 public function getCustomerEmail($object)
 {
     $email = $object->getCustomerEmail();
     if (empty($email)) {
         $email = $object->getBillingAddress()->getEmail();
     }
     return $email;
 }
コード例 #9
0
ファイル: Order.php プロジェクト: par-orillonsoft/app
 protected function _placeOrder($checkoutMessage, $orderStatus = 'pending', $notifyCreateOrder = false)
 {
     $this->_quote->collectTotals();
     $this->_quote->reserveOrderId();
     error_reporting(E_ERROR);
     $service = Mage::getModel('sales/service_quote', $this->_quote);
     // If file not exist may catch warring
     error_reporting(E_ALL);
     if ($service != false && method_exists($service, 'submitAll')) {
         // Magento version 1.4.1.x
         //  $service = Mage::getModel('sales/service_quote', $quote);
         $service->submitAll();
         $orderObj = $service->getOrder();
     } else {
         // Magento version 1.4.0.x , 1.3.x
         $convertQuoteObj = Mage::getSingleton('sales/convert_quote');
         $orderObj = $convertQuoteObj->addressToOrder($this->_quote->getShippingAddress());
         $orderObj->setBillingAddress($convertQuoteObj->addressToOrderAddress($this->_quote->getBillingAddress()));
         $orderObj->setShippingAddress($convertQuoteObj->addressToOrderAddress($this->_quote->getShippingAddress()));
         $orderObj->setPayment($convertQuoteObj->paymentToOrderPayment($this->_quote->getPayment()));
         $items = $this->_quote->getShippingAddress()->getAllItems();
         foreach ($items as $item) {
             //@var $item Mage_Sales_Model_Quote_Item
             $orderItem = $convertQuoteObj->itemToOrderItem($item);
             if ($item->getParentItem()) {
                 $orderItem->setParentItem($orderObj->getItemByQuoteItemId($item->getParentItem()->getId()));
             }
             $orderObj->addItem($orderItem);
         }
         $orderObj->setCanShipPartiallyItem(false);
         $orderObj->place();
     }
     $orderMessages = '';
     $notifyMessages = $this->_processNotifyMessage();
     if ($checkoutMessage || $notifyMessages) {
         $orderMessages .= '<br /><b><u>' . Mage::helper('M2ePro')->__('M2E Pro Notes') . ':</u></b><br /><br />';
         if ($checkoutMessage) {
             $orderMessages .= '<b>' . Mage::helper('M2ePro')->__('Checkout Message From Buyer') . ':</b>';
             $orderMessages .= $checkoutMessage . '<br />';
         }
         if ($notifyMessages) {
             $orderMessages .= $notifyMessages;
         }
     }
     // Adding notification to order
     $orderObj->addStatusToHistory($orderStatus, $orderMessages, false);
     $orderObj->save();
     // --------------------
     Mage::helper('M2ePro/Module')->getConfig()->setGroupValue('/synchronization/orders/', 'current_magento_order_id', $orderObj->getId());
     $this->setFatalErrorHandler();
     // --------------------
     // Send Notification to customer after create order
     if ($notifyCreateOrder) {
         // Send new order E-mail only if select such mode
         $orderObj->sendNewOrderEmail();
     }
     return $orderObj;
 }
コード例 #10
0
ファイル: Checkout.php プロジェクト: ksaltik/tooldexlive
 /**
  * Make sure addresses will be saved without validation errors
  */
 private function _ignoreAddressValidation()
 {
     $this->_quote->getBillingAddress()->setShouldIgnoreValidation(true);
     if (!$this->_quote->getIsVirtual()) {
         $this->_quote->getShippingAddress()->setShouldIgnoreValidation(true);
         if (!$this->_config->requireBillingAddress && !$this->_quote->getBillingAddress()->getEmail()) {
             $this->_quote->getBillingAddress()->setSameAsBilling(1);
         }
     }
 }
コード例 #11
0
 /**
  * @param Mage_Sales_Model_Quote $quote
  * @return array
  */
 protected function _buildParams($quote)
 {
     $billingAddress = $quote->getBillingAddress();
     $gender = 'female';
     if ($quote->getCustomerGender() == self::GENDER_MALE) {
         $gender = 'male';
     }
     $street = preg_split("/\\s+(?=\\S*+\$)/", $billingAddress->getStreet1());
     $params = array('gender' => $gender, 'firstname' => $billingAddress->getFirstname(), 'lastname' => $billingAddress->getLastname(), 'country' => $billingAddress->getCountry(), 'street' => $street[0], 'housenumber' => $street[1], 'zip' => $billingAddress->getPostcode(), 'city' => $billingAddress->getCity(), 'birthday' => $this->_formatDob($quote->getCustomerDob()), 'currency' => 'EUR', 'amount' => $this->_formatAmount($quote->getGrandTotal()));
     return $params;
 }
コード例 #12
0
ファイル: Quote.php プロジェクト: ReeceCrossland/essua-m2epro
 private function initializeAddresses()
 {
     $billingAddress = $this->quote->getBillingAddress();
     $billingAddress->addData($this->proxyOrder->getBillingAddressData());
     $billingAddress->implodeStreetAddress();
     $billingAddress->setLimitCarrier('m2eproshipping');
     $billingAddress->setShippingMethod('m2eproshipping_m2eproshipping');
     $billingAddress->setCollectShippingRates(true);
     $billingAddress->setShouldIgnoreValidation($this->proxyOrder->shouldIgnoreBillingAddressValidation());
     // ---------------------------------------
     $shippingAddress = $this->quote->getShippingAddress();
     $shippingAddress->setSameAsBilling(0);
     // maybe just set same as billing?
     $shippingAddress->addData($this->proxyOrder->getAddressData());
     $shippingAddress->implodeStreetAddress();
     $shippingAddress->setLimitCarrier('m2eproshipping');
     $shippingAddress->setShippingMethod('m2eproshipping_m2eproshipping');
     $shippingAddress->setCollectShippingRates(true);
     // ---------------------------------------
 }
コード例 #13
0
 /**
  * Validate customer data and set some its data for further usage in quote
  * Will return either true or array with error messages
  *
  * @param Mage_Sales_Model_Quote $quote
  * @param array $data
  * @return true|array
  */
 public function validateCustomerData($quote, array $data, $registerMethod)
 {
     /** @var $customerForm Mage_Customer_Model_Form */
     $customerForm = Mage::getModel('customer/form');
     $customerForm->setFormCode('customer_account_create');
     if ($quote->getCustomerId()) {
         $customer = $quote->getCustomer();
         $customerForm->setEntity($customer);
         $customerData = $quote->getCustomer()->getData();
     } else {
         /* @var $customer Mage_Customer_Model_Customer */
         $customer = Mage::getModel('customer/customer');
         $customerForm->setEntity($customer);
         $customerRequest = $customerForm->prepareRequest($data);
         $customerData = $customerForm->extractData($customerRequest);
     }
     $customerErrors = $customerForm->validateData($customerData);
     if ($customerErrors !== true) {
         return $customerErrors;
     }
     if ($quote->getCustomerId()) {
         return true;
     }
     $customerForm->compactData($customerData);
     if ($registerMethod == 'register') {
         // set customer password
         $customer->setPassword($customerRequest->getParam('customer_password'));
         $customer->setConfirmation($customerRequest->getParam('confirm_password'));
         $customer->setPasswordConfirmation($customerRequest->getParam('confirm_password'));
     } else {
         // spoof customer password for guest
         $password = $customer->generatePassword();
         $customer->setPassword($password);
         $customer->setConfirmation($password);
         $customer->setPasswordConfirmation($password);
         // set NOT LOGGED IN group id explicitly,
         // otherwise copyFieldset('customer_account', 'to_quote') will fill it with default group id value
         $customer->setGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
     }
     $result = $customer->validate();
     if (true !== $result && is_array($result)) {
         return implode(', ', $result);
     }
     if ($registerMethod == 'register') {
         // save customer encrypted password in quote
         $quote->setPasswordHash($customer->encryptPassword($customer->getPassword()));
     }
     // copy customer/guest email to address
     $quote->getBillingAddress()->setEmail($customer->getEmail());
     // copy customer data to quote
     Mage::helper('core')->copyFieldset('customer_account', 'to_quote', $customer, $quote);
     return true;
 }
コード例 #14
0
 /**
  * get some method dependend form fields 
  *
  * @param Mage_Sales_Model_Quote $order
  * @return array
  */
 public function getMethodDependendFormFields($order, $requestParams = null)
 {
     $billingAddress = $order->getBillingAddress();
     $shippingAddress = $order->getShippingAddress();
     $street = str_replace("\n", ' ', $billingAddress->getStreet(-1));
     $regexp = '/^([^0-9]*)([0-9].*)$/';
     if (!preg_match($regexp, $street, $splittedStreet)) {
         $splittedStreet[1] = $street;
         $splittedStreet[2] = '';
     }
     $formFields = parent::getMethodDependendFormFields($order, $requestParams);
     $gender = Mage::getSingleton('eav/config')->getAttribute('customer', 'gender')->getSource()->getOptionText($order->getCustomerGender());
     $formFields['CIVILITY'] = $gender == 'Male' ? 'M' : 'V';
     $formFields['OWNERADDRESS'] = trim($splittedStreet[1]);
     $formFields['ECOM_BILLTO_POSTAL_STREET_NUMBER'] = trim($splittedStreet[2]);
     $formFields['OWNERZIP'] = $billingAddress->getPostcode();
     $formFields['OWNERTOWN'] = $billingAddress->getCity();
     $formFields['OWNERCTY'] = $billingAddress->getCountry();
     $formFields['OWNERTELNO'] = $billingAddress->getTelephone();
     $street = str_replace("\n", ' ', $shippingAddress->getStreet(-1));
     if (!preg_match($regexp, $street, $splittedStreet)) {
         $splittedStreet[1] = $street;
         $splittedStreet[2] = '';
     }
     $formFields['ECOM_SHIPTO_POSTAL_NAME_PREFIX'] = $shippingAddress->getPrefix();
     $formFields['ECOM_SHIPTO_POSTAL_NAME_FIRST'] = $shippingAddress->getFirstname();
     $formFields['ECOM_SHIPTO_POSTAL_NAME_LAST'] = $shippingAddress->getLastname();
     $formFields['ECOM_SHIPTO_POSTAL_STREET_LINE1'] = trim($splittedStreet[1]);
     $formFields['ECOM_SHIPTO_POSTAL_STREET_NUMBER'] = trim($splittedStreet[2]);
     $formFields['ECOM_SHIPTO_POSTAL_POSTALCODE'] = $shippingAddress->getPostcode();
     $formFields['ECOM_SHIPTO_POSTAL_CITY'] = $shippingAddress->getCity();
     $formFields['ECOM_SHIPTO_POSTAL_COUNTRYCODE'] = $shippingAddress->getCountry();
     // copy some already known values
     $formFields['ECOM_SHIPTO_ONLINE_EMAIL'] = $order->getCustomerEmail();
     if (is_array($requestParams)) {
         if (array_key_exists('OWNERADDRESS', $requestParams)) {
             $formFields['OWNERADDRESS'] = $requestParams['OWNERADDRESS'];
         }
         if (array_key_exists('ECOM_BILLTO_POSTAL_STREET_NUMBER', $requestParams)) {
             $formFields['ECOM_BILLTO_POSTAL_STREET_NUMBER'] = $requestParams['ECOM_BILLTO_POSTAL_STREET_NUMBER'];
         }
         if (array_key_exists('ECOM_SHIPTO_POSTAL_STREET_LINE1', $requestParams)) {
             $formFields['ECOM_SHIPTO_POSTAL_STREET_LINE1'] = $requestParams['ECOM_SHIPTO_POSTAL_STREET_LINE1'];
         }
         if (array_key_exists('ECOM_SHIPTO_POSTAL_STREET_NUMBER', $requestParams)) {
             $formFields['ECOM_SHIPTO_POSTAL_STREET_NUMBER'] = $requestParams['ECOM_SHIPTO_POSTAL_STREET_NUMBER'];
         }
     }
     return $formFields;
 }
コード例 #15
0
 /**
  * Set up the billing address for the quote and on the customer, and set the customer's
  * default billing address.
  *
  * @param $customer Mage_Customer_Model_Customer
  *
  * @return Mage_Sales_Model_Quote_Address $billingAddress | null
  */
 protected function _prepareCustomerBilling(Mage_Customer_Model_Customer $customer)
 {
     $billing = $this->_quote->getBillingAddress();
     if (!$billing->getCustomerId() || $billing->getSaveInAddressBook()) {
         $customerBilling = $billing->exportCustomerAddress();
         $customer->addAddress($customerBilling);
         $billing->setCustomerAddress($customerBilling);
         if (!$customer->getDefaultBilling()) {
             $customerBilling->setIsDefaultBilling(true);
         }
         return $customerBilling;
     }
     return null;
 }
コード例 #16
0
ファイル: Quote.php プロジェクト: AleksNesh/pandora
 /**
  * Apply shipping/billing address to quote
  *
  * @param Mage_Sales_Model_Quote $quote
  * @param $data
  * @param $addressType
  * @return $this
  */
 public function setAddress(Mage_Sales_Model_Quote $quote, $data, $addressType)
 {
     $address = $addressType == 'shipping' ? $quote->getShippingAddress() : $quote->getBillingAddress();
     $address->addData($data);
     // fix for street fields
     $streetArray = array();
     for ($i = 0; $i < 4; $i++) {
         if (isset($data['street[' . $i])) {
             $streetArray[$i] = $data['street[' . $i];
         }
     }
     $street = implode(chr(10), $streetArray);
     $streetData = array('street' => $street);
     $address->addData($streetData);
     // fix end
     return $this;
 }
コード例 #17
0
 /**
  * @param Mage_Sales_Model_Quote $quote
  * @return Payone_Api_Request_Parameter_ManageMandate_PersonalData
  */
 protected function mapPersonalData(Mage_Sales_Model_Quote $quote)
 {
     $billingAddress = $quote->getBillingAddress();
     $helper = $this->helper();
     $personalData = new Payone_Api_Request_Parameter_ManageMandate_PersonalData();
     if ($quote->getCustomerId()) {
         $personalData->setCustomerid($quote->getCustomerId());
     }
     $personalData->setLastname($billingAddress->getLastname());
     $personalData->setFirstname($billingAddress->getFirstname());
     if ($billingAddress->getCompany()) {
         $personalData->setCompany($billingAddress->getCompany());
     }
     $personalData->setStreet($helper->normalizeStreet($billingAddress->getStreet()));
     $personalData->setZip($billingAddress->getPostcode());
     $personalData->setCity($billingAddress->getCity());
     $personalData->setCountry($billingAddress->getCountry());
     $personalData->setEmail($billingAddress->getEmail());
     $personalData->setLanguage($helper->getDefaultLanguage());
     return $personalData;
 }
コード例 #18
0
ファイル: Random.php プロジェクト: hirentricore/devmagento
 public function render()
 {
     $customer = $this->_getCustomer();
     $this->_quote->setStore($this->_getStore())->setCustomer($customer);
     $this->_quote->getBillingAddress()->importCustomerAddress($customer->getDefaultBillingAddress());
     $this->_quote->getShippingAddress()->importCustomerAddress($customer->getDefaultShippingAddress());
     $productCount = rand(3, 10);
     for ($i = 0; $i < $productCount; $i++) {
         $product = $this->_getRandomProduct();
         if ($product) {
             $product->setQuoteQty(1);
             $this->_quote->addCatalogProduct($product);
         }
     }
     $this->_quote->getPayment()->setMethod('checkmo');
     $this->_quote->getShippingAddress()->setShippingMethod('freeshipping_freeshipping');
     //->collectTotals()->save();
     $this->_quote->getShippingAddress()->setCollectShippingRates(true);
     $this->_quote->collectTotals()->save();
     $this->_quote->save();
     return $this;
 }
コード例 #19
0
 /**
  * Changed By Adam 06/11/2014: Fix bug hidden tax
  * pre collect total for quote/address and return quote total
  * 
  * @param Mage_Sales_Model_Quote $quote
  * @param null|Mage_Sales_Model_Quote_Address $address
  * @return float
  */
 public function getQuoteBaseTotal($quote, $address = null)
 {
     $cacheKey = 'quote_base_total';
     if ($this->hasCache($cacheKey)) {
         return $this->getCache($cacheKey);
     }
     if (is_null($address)) {
         if ($quote->isVirtual()) {
             $address = $quote->getBillingAddress();
         } else {
             $address = $quote->getShippingAddress();
         }
     }
     $baseTotal = 0;
     foreach ($address->getAllItems() as $item) {
         if ($item->getParentItemId()) {
             continue;
         }
         if ($item->getHasChildren() && $item->isChildrenCalculated()) {
             foreach ($item->getChildren() as $child) {
                 $baseTotal += $item->getQty() * ($child->getQty() * $this->_getItemBasePrice($child)) - $child->getBaseDiscountAmount() - $child->getMagestoreBaseDiscount();
             }
         } elseif ($item->getProduct()) {
             $baseTotal += $item->getQty() * $this->_getItemBasePrice($item) - $item->getBaseDiscountAmount() - $item->getMagestoreBaseDiscount();
         }
     }
     //        if (Mage::getStoreConfig(self::XML_PATH_SPEND_FOR_SHIPPING, $quote->getStoreId())) {
     //            $shippingAmount = $address->getShippingAmountForDiscount();
     //            if ($shippingAmount !== null) {
     //                $baseShippingAmount = $address->getBaseShippingAmountForDiscount();
     //            } else {
     //                $baseShippingAmount = $address->getBaseShippingAmount();
     //            }
     //            $baseTotal += $baseShippingAmount - $address->getBaseShippingDiscountAmount() - $address->getMagestoreBaseDiscountForShipping();
     //        }
     $this->saveCache($cacheKey, $baseTotal);
     return $baseTotal;
 }
コード例 #20
0
 /**
  * Returns shiping or billing address of given quote
  * regarding configuration
  * 
  * @param Mage_Sales_Model_Quote $quote
  */
 public function getAddress($quote)
 {
     switch ($this->config->get('solvency/address_type')) {
         case Netresearch_Scoring_Model_System_Config_Source_Address_Type::BILLING:
             return $quote->getBillingAddress();
         default:
             return $quote->getShippingAddress();
     }
 }
コード例 #21
0
ファイル: Data.php プロジェクト: shabirm/avatax
 /**
  * Determines if the object (quote, invoice, or credit memo) should use AvaTax services
  *
  * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order_Invoice|Mage_Sales_Model_Order_Creditmemo $object
  * @param Mage_Sales_Model_Quote_Address $shippingAddress
  * @return bool
  */
 public function isObjectActionable($object, $shippingAddress = null)
 {
     $storeId = $object->getStore()->getId();
     //is action enabled?
     $action = $object->getOrder() ? OnePica_AvaTax_Model_Config::ACTION_CALC_SUBMIT : OnePica_AvaTax_Model_Config::ACTION_CALC;
     if (Mage::getStoreConfig('tax/avatax/action', $storeId) < $action) {
         return false;
     }
     if (!$shippingAddress) {
         $shippingAddress = $object->getShippingAddress();
     }
     if (!$shippingAddress) {
         $shippingAddress = $object->getBillingAddress();
     }
     //is the region filtered?
     if (!$this->isAddressActionable($shippingAddress, $storeId, OnePica_AvaTax_Model_Config::REGIONFILTER_TAX)) {
         return false;
     }
     return true;
 }
コード例 #22
0
ファイル: Payment.php プロジェクト: GaynorH/prestigedrinks
 /**
  * Return customer data in xml format.
  *
  * @param Mage_Sales_Model_Quote $quote
  * @return string Xml data
  */
 public function getCustomerXml($quote)
 {
     $_xml = null;
     $checkoutMethod = Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod();
     if ($checkoutMethod) {
         $customer = new Varien_Object();
         switch ($checkoutMethod) {
             case 'register':
             case 'guest':
                 $customer->setMiddlename($quote->getBillingAddress()->getMiddlename());
                 $customer->setPreviousCustomer('0');
                 break;
             case 'customer':
                 //Load customer by Id
                 $customer = $quote->getCustomer();
                 $customer->setPreviousCustomer('1');
                 break;
             default:
                 $customer = $quote->getCustomer();
                 $customer->setPreviousCustomer('0');
                 break;
         }
         $customer->setWorkPhone($quote->getBillingAddress()->getFax());
         $customer->setMobilePhone($quote->getBillingAddress()->getTelephone());
         $xml = new Ebizmarts_Simplexml_Element('<customer />');
         if ($customer->getMiddlename()) {
             $xml->addChild('customerMiddleInitial', substr($customer->getMiddlename(), 0, 1));
         }
         if ($customer->getDob()) {
             $_dob = substr($customer->getDob(), 0, strpos($customer->getDob(), ' '));
             if ($_dob != "0000-00-00") {
                 $xml->addChildCData('customerBirth', $_dob);
                 //YYYY-MM-DD
             }
         }
         if ($customer->getWorkPhone()) {
             $xml->addChildCData('customerWorkPhone', substr(str_pad($customer->getWorkPhone(), 11, '0', STR_PAD_RIGHT), 0, 19));
         }
         if ($customer->getMobilePhone()) {
             $xml->addChildCData('customerMobilePhone', substr(str_pad($customer->getMobilePhone(), 11, '0', STR_PAD_RIGHT), 0, 19));
         }
         $xml->addChild('previousCust', $customer->getPreviousCustomer());
         if ($customer->getId()) {
             $xml->addChild('customerId', $customer->getId());
         }
         //$xml->addChild('timeOnFile', 10);
         $_xml = str_replace("\n", "", trim($xml->asXml()));
     }
     return $_xml;
 }
コード例 #23
0
ファイル: Review.php プロジェクト: blazeriaz/youguess
 /**
  * Return quote billing address
  *
  * @return Mage_Sales_Model_Quote_Address
  */
 public function getBillingAddress()
 {
     return $this->_quote->getBillingAddress();
 }
コード例 #24
0
ファイル: Abstract.php プロジェクト: technomagegithub/olgo.nl
 /**
  * Get the tax request object for the current quote.
  *
  * @param Mage_Sales_Model_Quote $quote
  *
  * @return bool|Varien_Object
  */
 protected function _getBuckarooFeeTaxRequest(Mage_Sales_Model_Quote $quote)
 {
     $store = $quote->getStore();
     $codTaxClass = Mage::getStoreConfig(self::XPATH_BUCKAROO_TAX_CLASS, $store);
     /**
      * If no tax class is configured for the Buckaroo fee, there is no tax to be calculated.
      */
     if (!$codTaxClass) {
         return false;
     }
     $taxCalculation = $this->getTaxCalculation();
     $customerTaxClass = $quote->getCustomerTaxClassId();
     $shippingAddress = $quote->getShippingAddress();
     $billingAddress = $quote->getBillingAddress();
     $request = $taxCalculation->getRateRequest($shippingAddress, $billingAddress, $customerTaxClass, $store);
     $request->setProductClassId($codTaxClass);
     return $request;
 }
コード例 #25
0
ファイル: Alias.php プロジェクト: roshu1980/add-computers
 public function setAliasToActiveAfterUserRegisters(Mage_Sales_Model_Order $order, Mage_Sales_Model_Quote $quote)
 {
     if (true === $quote->getPayment()->getAdditionalInformation('userIsRegistering')) {
         $customerId = $order->getCustomerId();
         $billingAddressHash = $this->generateAddressHash($quote->getBillingAddress());
         $shippingAddressHash = $this->generateAddressHash($quote->getShippingAddress());
         $aliasId = $quote->getPayment()->getAdditionalInformation('opsAliasId');
         if (is_numeric($aliasId) && 0 < $aliasId) {
             $alias = Mage::getModel('ops/alias')->getCollection()->addFieldToFilter('alias', $quote->getPayment()->getAdditionalInformation('alias'))->addFieldToFilter('billing_address_hash', $billingAddressHash)->addFieldToFilter('shipping_address_hash', $shippingAddressHash)->addFieldToFilter('store_id', array('eq' => $quote->getStoreId()))->getFirstItem();
             if ($alias->getState() === Netresearch_OPS_Model_Alias_State::PENDING) {
                 $alias->setState(Netresearch_OPS_Model_Alias_State::ACTIVE);
                 $alias->setCustomerId($customerId);
                 $alias->save();
             }
         }
     }
 }
コード例 #26
0
ファイル: Abstract.php プロジェクト: virtual97/avatax
 /**
  * Sets the customer info if available
  *
  * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $object
  * @return $this
  */
 protected function _addCustomer($object)
 {
     $format = Mage::getStoreConfig('tax/avatax/cust_code_format', $object->getStoreId());
     $customer = Mage::getModel('customer/customer');
     if ($object->getCustomerId()) {
         $customer->load($object->getCustomerId());
         $taxClass = Mage::getModel('tax/class')->load($customer->getTaxClassId())->getOpAvataxCode();
         $this->_request->setCustomerUsageType($taxClass);
     }
     switch ($format) {
         case OnePica_AvaTax_Model_Source_Customercodeformat::LEGACY:
             if ($customer->getId()) {
                 $customerCode = $customer->getName() . ' (' . $customer->getId() . ')';
             } else {
                 $address = $object->getBillingAddress() ? $object->getBillingAddress() : $object;
                 $customerCode = $address->getFirstname() . ' ' . $address->getLastname() . ' (Guest)';
             }
             break;
         case OnePica_AvaTax_Model_Source_Customercodeformat::CUST_EMAIL:
             $customerCode = $object->getCustomerEmail() ? $object->getCustomerEmail() : $customer->getEmail();
             break;
         case OnePica_AvaTax_Model_Source_Customercodeformat::CUST_ID:
         default:
             $customerCode = $object->getCustomerId() ? $object->getCustomerId() : 'guest-' . $object->getId();
             break;
     }
     $this->_request->setCustomerCode($customerCode);
     return $this;
 }
コード例 #27
0
ファイル: Data.php プロジェクト: natxetee/magento2
 /**
  * Send email id payment was failed
  *
  * @param Mage_Sales_Model_Quote $checkout
  * @param string $message
  * @param string $checkoutType
  * @return Mage_Checkout_Helper_Data
  */
 public function sendPaymentFailedEmail($checkout, $message, $checkoutType = 'onepage')
 {
     $translate = Mage::getSingleton('Mage_Core_Model_Translate');
     /* @var $translate Mage_Core_Model_Translate */
     $translate->setTranslateInline(false);
     $mailTemplate = Mage::getModel('Mage_Core_Model_Email_Template');
     /* @var $mailTemplate Mage_Core_Model_Email_Template */
     $template = Mage::getStoreConfig('checkout/payment_failed/template', $checkout->getStoreId());
     $copyTo = $this->_getEmails('checkout/payment_failed/copy_to', $checkout->getStoreId());
     $copyMethod = Mage::getStoreConfig('checkout/payment_failed/copy_method', $checkout->getStoreId());
     if ($copyTo && $copyMethod == 'bcc') {
         $mailTemplate->addBcc($copyTo);
     }
     $_reciever = Mage::getStoreConfig('checkout/payment_failed/reciever', $checkout->getStoreId());
     $sendTo = array(array('email' => Mage::getStoreConfig('trans_email/ident_' . $_reciever . '/email', $checkout->getStoreId()), 'name' => Mage::getStoreConfig('trans_email/ident_' . $_reciever . '/name', $checkout->getStoreId())));
     if ($copyTo && $copyMethod == 'copy') {
         foreach ($copyTo as $email) {
             $sendTo[] = array('email' => $email, 'name' => null);
         }
     }
     $shippingMethod = '';
     if ($shippingInfo = $checkout->getShippingAddress()->getShippingMethod()) {
         $data = explode('_', $shippingInfo);
         $shippingMethod = $data[0];
     }
     $paymentMethod = '';
     if ($paymentInfo = $checkout->getPayment()) {
         $paymentMethod = $paymentInfo->getMethod();
     }
     $items = '';
     foreach ($checkout->getAllVisibleItems() as $_item) {
         /* @var $_item Mage_Sales_Model_Quote_Item */
         $items .= $_item->getProduct()->getName() . '  x ' . $_item->getQty() . '  ' . $checkout->getStoreCurrencyCode() . ' ' . $_item->getProduct()->getFinalPrice($_item->getQty()) . "\n";
     }
     $total = $checkout->getStoreCurrencyCode() . ' ' . $checkout->getGrandTotal();
     foreach ($sendTo as $recipient) {
         $mailTemplate->setDesignConfig(array('area' => Mage_Core_Model_App_Area::AREA_FRONTEND, 'store' => $checkout->getStoreId()))->sendTransactional($template, Mage::getStoreConfig('checkout/payment_failed/identity', $checkout->getStoreId()), $recipient['email'], $recipient['name'], array('reason' => $message, 'checkoutType' => $checkoutType, 'dateAndTime' => Mage::app()->getLocale()->date(), 'customer' => $checkout->getCustomerFirstname() . ' ' . $checkout->getCustomerLastname(), 'customerEmail' => $checkout->getCustomerEmail(), 'billingAddress' => $checkout->getBillingAddress(), 'shippingAddress' => $checkout->getShippingAddress(), 'shippingMethod' => Mage::getStoreConfig('carriers/' . $shippingMethod . '/title'), 'paymentMethod' => Mage::getStoreConfig('payment/' . $paymentMethod . '/title'), 'items' => nl2br($items), 'total' => $total));
     }
     $translate->setTranslateInline(true);
     return $this;
 }
コード例 #28
0
ファイル: Abstract.php プロジェクト: technomagegithub/colb2b
 /**
  * Check whether payment method is applicable to quote
  * Purposed to allow use in controllers some logic that was implemented in blocks only before
  *
  * @param Mage_Sales_Model_Quote $quote
  * @param int|null $checksBitMask
  * @return bool
  */
 public function isApplicableToQuote($quote, $checksBitMask)
 {
     if ($checksBitMask & self::CHECK_USE_FOR_COUNTRY) {
         if (!$this->canUseForCountry($quote->getBillingAddress()->getCountry())) {
             return false;
         }
     }
     if ($checksBitMask & self::CHECK_USE_FOR_CURRENCY) {
         if (!$this->canUseForCurrency($quote->getStore()->getBaseCurrencyCode())) {
             return false;
         }
     }
     if ($checksBitMask & self::CHECK_USE_CHECKOUT) {
         if (!$this->canUseCheckout()) {
             return false;
         }
     }
     if ($checksBitMask & self::CHECK_USE_FOR_MULTISHIPPING) {
         if (!$this->canUseForMultishipping()) {
             return false;
         }
     }
     if ($checksBitMask & self::CHECK_USE_INTERNAL) {
         if (!$this->canUseInternal()) {
             return false;
         }
     }
     if ($checksBitMask & self::CHECK_ORDER_TOTAL_MIN_MAX) {
         $total = $quote->getBaseGrandTotal();
         $minTotal = $this->getConfigData('min_order_total');
         $maxTotal = $this->getConfigData('max_order_total');
         if (!empty($minTotal) && $total < $minTotal || !empty($maxTotal) && $total > $maxTotal) {
             return false;
         }
     }
     if ($checksBitMask & self::CHECK_RECURRING_PROFILES) {
         if (!$this->canManageRecurringProfiles() && $quote->hasRecurringItems()) {
             return false;
         }
     }
     if ($checksBitMask & self::CHECK_ZERO_TOTAL) {
         $total = $quote->getBaseSubtotal() + $quote->getShippingAddress()->getBaseShippingAmount();
         if ($total < 0.0001 && $this->getCode() != 'free' && !($this->canManageRecurringProfiles() && $quote->hasRecurringItems())) {
             return false;
         }
     }
     return true;
 }
コード例 #29
0
ファイル: Customer.php プロジェクト: cnglobal-sl/caterez
 /**
  * Prepare quote for customer order submit
  *
  * @param Mage_Sales_Model_Quote $quote
  * @return Mage_Checkout_Model_Api_Resource_Customer
  */
 protected function _prepareCustomerQuote(Mage_Sales_Model_Quote $quote)
 {
     $billing = $quote->getBillingAddress();
     $shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
     $customer = $quote->getCustomer();
     if (!$billing->getCustomerId() || $billing->getSaveInAddressBook()) {
         $customerBilling = $billing->exportCustomerAddress();
         $customer->addAddress($customerBilling);
         $billing->setCustomerAddress($customerBilling);
     }
     if ($shipping && (!$shipping->getCustomerId() && !$shipping->getSameAsBilling() || !$shipping->getSameAsBilling() && $shipping->getSaveInAddressBook())) {
         $customerShipping = $shipping->exportCustomerAddress();
         $customer->addAddress($customerShipping);
         $shipping->setCustomerAddress($customerShipping);
     }
     if (isset($customerBilling) && !$customer->getDefaultBilling()) {
         $customerBilling->setIsDefaultBilling(true);
     }
     if ($shipping && isset($customerShipping) && !$customer->getDefaultShipping()) {
         $customerShipping->setIsDefaultShipping(true);
     } else {
         if (isset($customerBilling) && !$customer->getDefaultShipping()) {
             $customerBilling->setIsDefaultShipping(true);
         }
     }
     $quote->setCustomer($customer);
     return $this;
 }
コード例 #30
0
 /**
  * BillSAFE does not allow:
  * - virtual quotes
  * - differing shipping/billing address
  *
  * @param Mage_Sales_Model_Quote $quote
  * @return bool
  */
 protected function isAllowedBillSafe(Mage_Sales_Model_Quote $quote)
 {
     if ($quote->isVirtual()) {
         return false;
     }
     $billingAddress = $quote->getBillingAddress();
     $shippingAddress = $quote->getShippingAddress();
     if (!$shippingAddress->getSameAsBilling()) {
         // Double check, in case the customer has chosen to enter a separate shipping address, but filled in the same values as in billing address:
         if (!$this->helper()->addressesAreEqual($billingAddress, $shippingAddress)) {
             return false;
         }
     }
     return true;
 }