本文整理汇总了PHP中Mage_Sales_Model_Quote::getCustomerId方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Quote::getCustomerId方法的具体用法?PHP Mage_Sales_Model_Quote::getCustomerId怎么用?PHP Mage_Sales_Model_Quote::getCustomerId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Quote
的用法示例。
在下文中一共展示了Mage_Sales_Model_Quote::getCustomerId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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!'));
}
}
示例4: updateQuote
/**
* Update Quote Email Address if is guest and current email address assigned doesn't match new email
*
* @param Mage_Sales_Model_Quote $quote
*/
public function updateQuote(Mage_Sales_Model_Quote $quote)
{
$queue = Mage::getModel('bronto_emailcapture/queue');
$currentEmail = $queue->getCurrentEmail();
if (is_null($quote->getCustomerId()) && $queue->isValidEmail($currentEmail) && $quote->getCustomerEmail() !== $currentEmail) {
$quote->setCustomerEmail(Mage::getModel('bronto_emailcapture/queue')->getCurrentEmail())->save();
}
}
示例5: toOrder
/**
* Convert quote model to order model
*
* @param Mage_Sales_Model_Quote $quote
* @return Mage_Sales_Model_Order
*/
public function toOrder(Mage_Sales_Model_Quote $quote, $order = null)
{
if (!$order instanceof Mage_Sales_Model_Order) {
$order = Mage::getModel('sales/order');
}
/* @var $order Mage_Sales_Model_Order */
$order->setStoreId($quote->getStoreId())->setQuoteId($quote->getId())->setRemoteIp($quote->getRemoteIp())->setCustomerId($quote->getCustomerId())->setCustomerEmail($quote->getCustomerEmail())->setCustomerFirstname($quote->getCustomerFirstname())->setCustomerLastname($quote->getCustomerLastname())->setCustomerGroupId($quote->getCustomerGroupId())->setCustomerTaxClassId($quote->getCustomerTaxClassId())->setCustomerNote($quote->getCustomerNote())->setCustomerNoteNotify($quote->getCustomerNoteNotify())->setCustomerIsGuest($quote->getCustomerIsGuest())->setBaseCurrencyCode($quote->getBaseCurrencyCode())->setStoreCurrencyCode($quote->getStoreCurrencyCode())->setOrderCurrencyCode($quote->getQuoteCurrencyCode())->setStoreToBaseRate($quote->getStoreToBaseRate())->setStoreToOrderRate($quote->getStoreToQuoteRate())->setCouponCode($quote->getCouponCode())->setGiftcertCode($quote->getGiftcertCode())->setIsVirtual($quote->getIsVirtual())->setIsMultiPayment($quote->getIsMultiPayment())->setAppliedRuleIds($quote->getAppliedRuleIds());
Mage::dispatchEvent('sales_convert_quote_to_order', array('order' => $order, 'quote' => $quote));
return $order;
}
示例6: mapPersonalData
/**
* @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;
}
示例7: getGiftMessage
public function getGiftMessage()
{
if (!is_null($this->giftMessage)) {
return $this->giftMessage;
}
$giftMessageData = $this->proxyItem->getGiftMessage();
if (!is_array($giftMessageData)) {
return NULL;
}
$giftMessageData['customer_id'] = (int) $this->quote->getCustomerId();
/** @var $giftMessage Mage_GiftMessage_Model_Message */
$giftMessage = Mage::getModel('giftmessage/message')->addData($giftMessageData);
if ($giftMessage->isMessageEmpty()) {
return NULL;
}
$this->giftMessage = $giftMessage->save();
return $this->giftMessage;
}
示例8: goAction
/**
* Post transaction to SagePay - PayPal
*/
public function goAction()
{
try {
$this->_initCheckout();
$customer = Mage::getSingleton('customer/session')->getCustomer();
if (!$this->_quote->getCustomerId() && $customer && $customer->getId()) {
$this->_checkout->setCustomer($customer);
}
$rs = $this->_checkout->start();
if (is_string($rs)) {
$this->_redirectUrl($rs);
return;
}
} catch (Exception $e) {
$this->_getCheckoutSession()->addError($e->getMessage());
Ebizmarts_SagePaySuite_Log::we($e);
}
$this->_redirect('checkout/cart', array('_secure' => true));
return;
}
示例9: getCustomerBalanceModelFromSalesEntity
/**
* Get customer balance model using sales entity
*
* @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $salesEntity
*
* @return Enterprise_CustomerBalance_Model_Balance|bool
*/
public function getCustomerBalanceModelFromSalesEntity($salesEntity)
{
if ($salesEntity instanceof Mage_Sales_Model_Order) {
$customerId = $salesEntity->getCustomerId();
$quote = $salesEntity->getQuote();
} elseif ($salesEntity instanceof Mage_Sales_Model_Quote) {
$customerId = $salesEntity->getCustomer()->getId();
$quote = $salesEntity;
} else {
return false;
}
if (!$customerId) {
return false;
}
$customerBalanceModel = Mage::getModel('enterprise_customerbalance/balance')->setCustomerId($customerId)->setWebsiteId(Mage::app()->getStore($salesEntity->getStoreId())->getWebsiteId())->loadByCustomer();
if ($quote->getBaseCustomerBalanceVirtualAmount() > 0) {
$customerBalanceModel->setAmount($customerBalanceModel->getAmount() + $quote->getBaseCustomerBalanceVirtualAmount());
}
return $customerBalanceModel;
}
示例10: setTaxvat
/**
* Sets the vat id into the customer if not guest and always into the Quote/Order
*
* @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $quote
* @param string $taxvat
*/
public function setTaxvat($quote, $taxvat)
{
if ($quote->getCustomerId()) {
$quote->getCustomer()->setTaxvat($taxvat)->save();
}
$quote->setCustomerTaxvat($taxvat)->save();
}
示例11: _paymentDataImport
/**
* Prepare and set to quote reward balance instance,
* set zero subtotal checkout payment if need
*
* @param Mage_Sales_Model_Quote $quote
* @param Varien_Object $payment
* @param boolean $useRewardPoints
* @return Enterprise_Reward_Model_Observer
*/
protected function _paymentDataImport($quote, $payment, $useRewardPoints)
{
if (!$quote || !$quote->getCustomerId()) {
return $this;
}
$quote->setUseRewardPoints((bool) $useRewardPoints);
if ($quote->getUseRewardPoints()) {
/* @var $reward Enterprise_Reward_Model_Reward */
$reward = Mage::getModel('enterprise_reward/reward')->setCustomer($quote->getCustomer())->setWebsiteId($quote->getStore()->getWebsiteId())->loadByCustomer();
if ($reward->getId()) {
$quote->setRewardInstance($reward);
if (!$payment->getMethod()) {
$payment->setMethod('free');
}
} else {
$quote->setUseRewardPoints(false);
}
}
return $this;
}
示例12: _fillCartInformation
/**
* @param array $data
* @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $object
*/
private function _fillCartInformation(&$data, $object)
{
$productIids = array();
$productQtys = array();
$productStyleIds = array();
/** @var Mage_Sales_Model_Quote_Item|Mage_Sales_Model_Order_Item $item */
foreach ($object->getAllVisibleItems() as $item) {
$productIids[] = $item->getProduct()->getIid();
$productQtys[] = is_null($item->getQtyOrdered()) ? (int) $item->getQty() : (int) $item->getQtyOrdered();
$productStyleIds[] = $item->getProduct()->getNumber() . '-' . $item->getProduct()->getColorCode();
}
$data['productStyleId'] = implode(',', $productStyleIds);
$data['cartProductIds'] = implode(',', $productIids);
$data['cartProductQtys'] = implode(',', $productQtys);
$data['cartTotalNetto'] = round($object->getBaseSubtotal(), 2);
$data['cartTotalBrutto'] = round($object->getBaseGrandTotal(), 2);
$data['customerId'] = (int) $object->getCustomerId();
// For zanox tracking
if (array_key_exists('zanpid', $_COOKIE) && $_COOKIE['zanpid'] != '') {
$data['zanpid'] = $_COOKIE['zanpid'];
}
}
示例13: _registerQuote
/**
* register quote with connector
*
* @param Mage_Sales_Model_Quote $quote
*/
protected function _registerQuote(Mage_Sales_Model_Quote $quote)
{
try {
$connectorQuote = Mage::getModel('ddg_automation/quote');
$connectorQuote->setQuoteId($quote->getId())->setCustomerId($quote->getCustomerId())->setStoreId($quote->getStoreId())->save();
} catch (Exception $e) {
Mage::logException($e);
}
}
示例14: 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;
}
示例15: 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;
}