本文整理汇总了PHP中Mage_Sales_Model_Quote::setCustomerIsGuest方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Quote::setCustomerIsGuest方法的具体用法?PHP Mage_Sales_Model_Quote::setCustomerIsGuest怎么用?PHP Mage_Sales_Model_Quote::setCustomerIsGuest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Quote
的用法示例。
在下文中一共展示了Mage_Sales_Model_Quote::setCustomerIsGuest方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: placeOrder
/**
* Place the order when customer returned from paypal
* Until this moment all quote data must be valid
*
* @param string $token
* @param string $shippingMethodCode
* @return Mage_Sales_Model_Order
*/
public function placeOrder($token, $shippingMethodCode = null)
{
if ($shippingMethodCode) {
$this->updateShippingMethod($shippingMethodCode);
}
if (!$this->_quote->getCustomerId()) {
$this->_quote->setCustomerIsGuest(true)->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID)->setCustomerEmail($this->_quote->getBillingAddress()->getEmail());
}
$this->_ignoreAddressValidation();
$order = Mage::getModel('sales/service_quote', $this->_quote)->submit();
$this->_quote->save();
// commence redirecting to finish payment, if paypal requires it
if ($order->getPayment()->getAdditionalInformation(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_REDIRECT)) {
$this->_redirectUrl = $this->_config->getExpressCheckoutCompleteUrl($token);
}
switch ($order->getState()) {
// even after placement paypal can disallow to authorize/capture, but will wait until bank transfers money
case Mage_Sales_Model_Order::STATE_PENDING_PAYMENT:
// TODO
break;
// regular placement, when everything is ok
// regular placement, when everything is ok
case Mage_Sales_Model_Order::STATE_PROCESSING:
case Mage_Sales_Model_Order::STATE_COMPLETE:
$order->sendNewOrderEmail();
break;
}
return $order;
}
示例2: place
/**
* Place the order and recurring payment profiles when customer returned from paypal
* Until this moment all quote data must be valid
*/
public function place()
{
$isNewCustomer = false;
if ($this->_quote->getCheckoutMethod() == 'register') {
$isNewCustomer = $this->_prepareNewCustomerQuote();
} elseif (!$this->_quote->getCustomerId()) {
$this->_quote->setCustomerIsGuest(true)->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID)->setCustomerEmail($this->_quote->getBillingAddress()->getEmail());
} elseif ($this->_quote->getCustomerId()) {
if (!$this->_quote->getBillingAddress()->getCustomerAddressId()) {
$billingAddress = Mage::getModel('customer/address');
$billingAddress->setData($this->_quote->getBillingAddress()->getData())->setCustomerId($this->_quote->getCustomerId())->setSaveInAddressBook('0');
//->setIsDefaultBilling('1');
if ($this->_quote->getShippingAddress()->getData('same_as_billing')) {
$billingAddress->setIsDefaultShipping('0');
} else {
$shippingAddress = Mage::getModel('customer/address');
$shippingAddress->setData($this->_quote->getShippingAddress()->getData())->setCustomerId($this->_quote->getCustomerId())->setSaveInAddressBook('0')->setIsDefaultShipping('0');
$shippingAddress->save();
}
$billingAddress->save();
} else {
if ($this->_quote->getBillingAddress()->getSaveInAddressBook()) {
$newAddress = Mage::getModel('customer/address');
$newAddress->setData($this->_quote->getBillingAddress()->getData())->setCustomerId($this->_quote->getCustomerId())->setSaveInAddressBook('1')->save();
}
if ($this->_quote->getShippingAddress()->getSaveInAddressBook() && !$this->_quote->getShippingAddress()->getData('same_as_billing')) {
$newAddress = Mage::getModel('customer/address');
$newAddress->setData($this->_quote->getShippingAddress()->getData())->setCustomerId($this->_quote->getCustomerId())->setSaveInAddressBook('1')->save();
}
}
}
$this->_ignoreAddressValidation();
$this->_quote->collectTotals();
//set payment method as paypal
$this->_quote->getPayment()->setMethod("sagepaypaypal");
// commence redirecting to finish payment
$rs = Mage::getModel('sagepaysuite/sagePayDirectPro')->completePayPalTransaction(Mage::getSingleton('sagepaysuite/session')->getSagepaypaypalRqpost(), $this->_quote);
$service = Mage::getModel('sales/service_quote', $this->_quote);
$service->submitAll();
$this->_quote->save();
if ($isNewCustomer) {
try {
$this->_involveNewCustomer();
} catch (Exception $e) {
Mage::logException($e);
}
}
$order = $service->getOrder();
if (!$order) {
$dbtrn = Mage::getModel('sagepaysuite2/sagepaysuite_paypaltransaction')->loadByVendorTxCode(Mage::getSingleton('sagepaysuite/session')->getLastVendorTxCode());
if ($dbtrn->getId()) {
$dbtrn->setStatus('MAGE_ERROR')->setStatusDetail("Could not save order. " . $dbtrn->getStatusDetail())->save();
}
Mage::throwException('Could not save order. Please try again.');
return;
}
//Dispatching event, some modules need this to complete processing.
Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order' => $order, 'quote' => $this->_quote));
try {
$order->sendNewOrderEmail();
} catch (Exception $ex) {
Mage::logException($ex);
}
$this->_order = $order;
}
示例3: _setQuoteCustomer
/**
* @param Mage_Sales_Model_Quote $quote
* @param ShopgateCartBase $order
*
* @return Mage_Sales_Model_Quote
* @throws ShopgateLibraryException
*/
protected function _setQuoteCustomer($quote, $order)
{
/* @var $customer Mage_Customer_Model_Customer */
$customer = Mage::getModel('customer/customer');
$externalCustomerId = $order->getExternalCustomerId();
if ($externalCustomerId) {
$this->log('external customer id: ' . $externalCustomerId, ShopgateLogger::LOGTYPE_DEBUG);
$customer->load($externalCustomerId);
if (!$customer->getId()) {
throw new ShopgateLibraryException(ShopgateLibraryException::UNKNOWN_ERROR_CODE, sprintf('customer with external id \'%s\' does not exist', $externalCustomerId));
} else {
$quote->setCustomer($customer);
// also set customer in session some 3rd party plugins rely on it
Mage::getSingleton('customer/session')->setCustomer($customer)->setCustomerId($customer->getId())->setCustomerGroupId($customer->getGroupId());
$this->log('external customer loaded', ShopgateLogger::LOGTYPE_DEBUG);
}
}
$invoiceAddress = $order->getInvoiceAddress();
if ($invoiceAddress) {
$this->log('invoice address start', ShopgateLogger::LOGTYPE_DEBUG);
$quote->getBillingAddress()->setShouldIgnoreValidation(true);
$billingAddressData = $this->_getSalesHelper()->createAddressData($order, $order->getInvoiceAddress(), true);
$billingAddress = $quote->getBillingAddress()->addData($billingAddressData);
$this->log('invoice address end', ShopgateLogger::LOGTYPE_DEBUG);
}
$deliveryAddress = $order->getDeliveryAddress();
if ($deliveryAddress) {
$this->log('delivery address start', ShopgateLogger::LOGTYPE_DEBUG);
$quote->getShippingAddress()->setShouldIgnoreValidation(true);
$shippingAddressData = $this->_getSalesHelper()->createAddressData($order, $order->getDeliveryAddress(), false);
$shippingAddress = $quote->getShippingAddress()->addData($shippingAddressData);
$this->_getHelper()->setShippingMethod($shippingAddress, $order);
$this->log('delivery address end', ShopgateLogger::LOGTYPE_DEBUG);
}
$quote->setCustomerEmail($order->getMail());
$this->log('customer email: ' . $order->getMail(), ShopgateLogger::LOGTYPE_DEBUG);
if ($invoiceAddress) {
$this->log('invoice address start (names)', ShopgateLogger::LOGTYPE_DEBUG);
$quote->setCustomerPrefix($quote->getShippingAddress()->getPrefix());
$quote->setCustomerFirstname($invoiceAddress->getFirstName());
$quote->setCustomerLastname($invoiceAddress->getLastName());
$this->log('invoice address end (names)', ShopgateLogger::LOGTYPE_DEBUG);
}
$externalCustomerId = $order->getExternalCustomerId();
if (empty($externalCustomerId)) {
$this->log('external customer number unavailable', ShopgateLogger::LOGTYPE_DEBUG);
$quote->setCustomerIsGuest(1);
$quote->getShippingAddress();
$quote->getBillingAddress();
} else {
$this->log('external customer number available', ShopgateLogger::LOGTYPE_DEBUG);
$quote->setCustomerIsGuest(0);
if ($invoiceAddress) {
$billingAddress->setCustomerAddressId($invoiceAddress->getId());
}
if ($deliveryAddress) {
$shippingAddress->setCustomerAddressId($deliveryAddress->getId());
}
}
Mage::register('rule_data', new Varien_Object(array('store_id' => Mage::app()->getStore()->getId(), 'website_id' => Mage::app()->getStore()->getWebsiteId(), 'customer_group_id' => $quote->getCustomerGroupId())));
$quote->setIsActive('0');
$quote->setRemoteIp('shopgate.com');
$quote->save();
if (empty($externalCustomerId)) {
$quote->getBillingAddress()->isObjectNew(false);
$quote->getShippingAddress()->isObjectNew(false);
}
return $quote;
}
示例4: place
/**
* Place the order and recurring payment profiles when customer returned from paypal
* Until this moment all quote data must be valid
*/
public function place()
{
$isNewCustomer = false;
if ($this->_quote->getCheckoutMethod() == 'register') {
$this->_prepareNewCustomerQuote();
$isNewCustomer = true;
} elseif (!$this->_quote->getCustomerId()) {
$this->_quote->setCustomerIsGuest(true)->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID)->setCustomerEmail($this->_quote->getBillingAddress()->getEmail());
} elseif ($this->_quote->getCustomerId()) {
if (!$this->_quote->getBillingAddress()->getCustomerAddressId()) {
$billingAddress = Mage::getModel('customer/address');
$billingAddress->setData($this->_quote->getBillingAddress()->getData())->setCustomerId($this->_quote->getCustomerId())->setSaveInAddressBook('1')->setIsDefaultBilling('1');
if ($this->_quote->getShippingAddress()->getData('same_as_billing')) {
$billingAddress->setIsDefaultShipping('1');
} else {
$shippingAddress = Mage::getModel('customer/address');
$shippingAddress->setData($this->_quote->getShippingAddress()->getData())->setCustomerId($this->_quote->getCustomerId())->setSaveInAddressBook('1')->setIsDefaultShipping('1');
$shippingAddress->save();
}
$billingAddress->save();
} else {
if ($this->_quote->getBillingAddress()->getSaveInAddressBook()) {
$newAddress = Mage::getModel('customer/address');
$newAddress->setData($this->_quote->getBillingAddress()->getData())->setCustomerId($this->_quote->getCustomerId())->setSaveInAddressBook('1')->save();
}
if ($this->_quote->getShippingAddress()->getSaveInAddressBook() && !$this->_quote->getShippingAddress()->getData('same_as_billing')) {
$newAddress = Mage::getModel('customer/address');
$newAddress->setData($this->_quote->getShippingAddress()->getData())->setCustomerId($this->_quote->getCustomerId())->setSaveInAddressBook('1')->save();
}
}
}
$this->_ignoreAddressValidation();
$this->_quote->collectTotals();
// commence redirecting to finish payment
$rs = Mage::getModel('sagepaysuite/sagePayDirectPro')->completePayPalTransaction(Mage::getSingleton('sagepaysuite/session')->getSagepaypaypalRqpost(), $this->_quote);
$service = Mage::getModel('sales/service_quote', $this->_quote);
$service->submitAll();
$this->_quote->save();
if ($isNewCustomer) {
try {
$this->_involveNewCustomer();
} catch (Exception $e) {
Mage::logException($e);
}
}
$order = $service->getOrder();
if (!$order) {
return;
}
switch ($order->getState()) {
// even after placement paypal can disallow to authorize/capture, but will wait until bank transfers money
case Mage_Sales_Model_Order::STATE_PENDING_PAYMENT:
// TODO
break;
// regular placement, when everything is ok
// regular placement, when everything is ok
case Mage_Sales_Model_Order::STATE_PROCESSING:
case Mage_Sales_Model_Order::STATE_COMPLETE:
case Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW:
$order->sendNewOrderEmail();
break;
}
$this->_order = $order;
}
示例5:
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Magento
* @package Mage_Sales
* @subpackage integration_tests
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
$product = new Mage_Catalog_Model_Product();
$product->setTypeId('simple')->setId(1)->setAttributeSetId(4)->setName('Simple Product')->setSku('simple')->setPrice(10)->setStockData(array('use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1))->setMetaTitle('meta title')->setMetaKeyword('meta keyword')->setMetaDescription('meta description')->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED)->save();
$product->load(1);
$addressData = (include __DIR__ . '/address_data.php');
$billingAddress = new Mage_Sales_Model_Quote_Address($addressData);
$billingAddress->setAddressType('billing');
$shippingAddress = clone $billingAddress;
$shippingAddress->setId(null)->setAddressType('shipping');
$quote = new Mage_Sales_Model_Quote();
$quote->setCustomerIsGuest(true)->setStoreId(Mage::app()->getStore()->getId())->setReservedOrderId('test01')->setBillingAddress($billingAddress)->setShippingAddress($shippingAddress)->addProduct($product);
$quote->getPayment()->setMethod('checkmo');
$quote->setIsMultiShipping('1');
$quote->save();