本文整理汇总了PHP中Mage_Sales_Model_Quote::getBillingAddress方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Quote::getBillingAddress方法的具体用法?PHP Mage_Sales_Model_Quote::getBillingAddress怎么用?PHP Mage_Sales_Model_Quote::getBillingAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Quote
的用法示例。
在下文中一共展示了Mage_Sales_Model_Quote::getBillingAddress方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _ignoreAddressValidation
/**
* 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: createNewOrder
/**
* @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: getProductTaxRate
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: updateCustomer
/**
* 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: collect
/**
* 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: validateQuote
/**
* @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: validateAlias
/**
* 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: getCustomerEmail
/**
* 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: _placeOrder
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: _ignoreAddressValidation
/**
* 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: _buildParams
/**
* @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: initializeAddresses
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: validateCustomerData
/**
* 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: getMethodDependendFormFields
/**
* 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: _prepareCustomerBilling
/**
* 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;
}