本文整理汇总了PHP中Mage_Sales_Model_Quote::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Quote::getId方法的具体用法?PHP Mage_Sales_Model_Quote::getId怎么用?PHP Mage_Sales_Model_Quote::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Quote
的用法示例。
在下文中一共展示了Mage_Sales_Model_Quote::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _updateQuote
protected function _updateQuote(Mage_Sales_Model_Quote $quote)
{
if (!Mage::helper('recapture')->isEnabled()) {
return $this;
}
if (!$quote->getId()) {
return;
}
//sales_quote_save_before gets called like 5 times on some page loads, we don't want to do 5 updates per page load
if (Mage::registry('recapture_has_posted')) {
return;
}
Mage::register('recapture_has_posted', true);
$mediaConfig = Mage::getModel('catalog/product_media_config');
$storeId = Mage::app()->getStore();
$transportData = array('first_name' => $quote->getCustomerFirstname(), 'last_name' => $quote->getCustomerLastname(), 'email' => $quote->getCustomerEmail(), 'external_id' => $quote->getId(), 'grand_total' => $quote->getGrandTotal(), 'products' => array(), 'totals' => array());
$cartItems = $quote->getAllVisibleItems();
foreach ($cartItems as $item) {
$productModel = $item->getProduct();
$productImage = (string) Mage::helper('catalog/image')->init($productModel, 'thumbnail');
//check configurable first
if ($item->getProductType() == 'configurable') {
if (Mage::getStoreConfig('checkout/cart/configurable_product_image') == 'itself') {
$child = $productModel->getIdBySku($item->getSku());
$image = Mage::getResourceModel('catalog/product')->getAttributeRawValue($child, 'thumbnail', $storeId);
if ($image) {
$productImage = $mediaConfig->getMediaUrl($image);
}
}
}
//then check grouped
if (Mage::getStoreConfig('checkout/cart/grouped_product_image') == 'parent') {
$options = $productModel->getTypeInstance(true)->getOrderOptions($productModel);
if (isset($options['super_product_config']) && $options['super_product_config']['product_type'] == 'grouped') {
$parent = $options['super_product_config']['product_id'];
$image = Mage::getResourceModel('catalog/product')->getAttributeRawValue($parent, 'thumbnail', $storeId);
$productImage = $mediaConfig->getMediaUrl($image);
}
}
$optionsHelper = Mage::helper('catalog/product_configuration');
if ($item->getProductType() == 'configurable') {
$visibleOptions = $optionsHelper->getConfigurableOptions($item);
} else {
$visibleOptions = $optionsHelper->getCustomOptions($item);
}
$product = array('name' => $item->getName(), 'sku' => $item->getSku(), 'price' => $item->getPrice(), 'qty' => $item->getQty(), 'image' => $productImage, 'options' => $visibleOptions);
$transportData['products'][] = $product;
}
$totals = $quote->getTotals();
foreach ($totals as $total) {
//we pass grand total on the top level
if ($total->getCode() == 'grand_total') {
continue;
}
$total = array('name' => $total->getTitle(), 'amount' => $total->getValue());
$transportData['totals'][] = $total;
}
Mage::helper('recapture/transport')->dispatch('cart', $transportData);
return $this;
}
示例2: setQuote
/**
* Set Quote object to Collection
*
* @param Mage_Sales_Model_Quote $quote
* @return Mage_Sales_Model_Resource_Quote_Item_Collection
*/
public function setQuote($quote)
{
$this->_quote = $quote;
$quoteId = $quote->getId();
if ($quoteId) {
$this->addFieldToFilter('quote_id', $quote->getId());
} else {
$this->_totalRecords = 0;
$this->_setIsLoaded(true);
}
return $this;
}
示例3: getQuote
/**
* Retrieve quote model object
*
* @return Mage_Sales_Model_Quote
*/
public function getQuote()
{
if (is_null($this->_quote)) {
$this->_quote = Mage::getModel('sales/quote');
if ($this->getStoreId() && $this->getQuoteId()) {
$this->_quote->setStoreId($this->getStoreId())->load($this->getQuoteId());
} elseif ($this->getStoreId() && $this->hasCustomerId()) {
$this->_quote->setStoreId($this->getStoreId())->setCustomerGroupId(Mage::getStoreConfig(self::XML_PATH_DEFAULT_CREATEACCOUNT_GROUP))->assignCustomer($this->getCustomer())->setIsActive(false)->save();
$this->setQuoteId($this->_quote->getId());
}
$this->_quote->setIgnoreOldQty(true);
$this->_quote->setIsSuperMode(true);
}
return $this->_quote;
}
示例4: getQuote
/**
* Retrieve quote model object
*
* @return Mage_Sales_Model_Quote
*/
public function getQuote()
{
if (is_null($this->_quote)) {
$this->_quote = Mage::getModel('sales/quote');
if ($this->getStoreId() && $this->getQuoteId()) {
$this->_quote->setStoreId($this->getStoreId())->load($this->getQuoteId());
} elseif ($this->getStoreId()) {
$this->_quote->setStoreId($this->getStoreId())->assignCustomer($this->getCustomer())->setIsActive(false)->save();
$this->setQuoteId($this->_quote->getId());
}
$this->_quote->setIgnoreOldQty(true);
$this->_quote->setIsSuperMode(true);
}
return $this->_quote;
}
示例5: setUp
protected function setUp()
{
parent::setUp();
$quote = new Mage_Sales_Model_Quote();
$quote->load('test01', 'reserved_order_id');
Mage::getSingleton('Mage_Checkout_Model_Session')->setQuoteId($quote->getId());
}
示例6: 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;
}
示例7: 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->setIncrementId($quote->getReservedOrderId())->setStoreId($quote->getStoreId())->setQuoteId($quote->getId())->setCustomer($quote->getCustomer());
Mage::helper('core')->copyFieldset('sales_convert_quote', 'to_order', $quote, $order);
Mage::dispatchEvent('sales_convert_quote_to_order', array('order' => $order, 'quote' => $quote));
return $order;
}
示例8: testReviewAction
/**
* @magentoDataFixture Mage/Sales/_files/quote.php
* @magentoDataFixture Mage/Paypal/_files/quote_payment.php
*/
public function testReviewAction()
{
$quote = new Mage_Sales_Model_Quote();
$quote->load('test01', 'reserved_order_id');
Mage::getSingleton('Mage_Checkout_Model_Session')->setQuoteId($quote->getId());
$this->dispatch('paypal/express/review');
$html = $this->getResponse()->getBody();
$this->assertContains('Simple Product', $html);
$this->assertContains('Review', $html);
$this->assertContains('/paypal/express/placeOrder/', $html);
}
示例9: reactivateQuote
/**
* @param Mage_Sales_Model_Quote $quote
*/
protected function reactivateQuote(Mage_Sales_Model_Quote $quote)
{
if ($quote->getId()) {
/* @note: Reset reserved_order_id, Magento up to and including version 1.7 has a bug in Mage_Sales_Model_Resource_Quote::isOrderIncrementIdUsed()
* They cast the orderIncrementId to (int), which breaks the checkout/cart for all non-numerical incrementIds
* (Causes Integrity Constraint Violation, because orderIncrementId already exists */
$quote->setIsActive(1)->setReservedOrderId(null)->save();
$oSession = Mage::getSingleton('checkout/session');
$oSession->replaceQuote($quote)->unsLastRealOrderId();
}
}
示例10: testOverviewAction
/**
* Covers app/code/core/Mage/Checkout/Block/Multishipping/Payment/Info.php
* and app/code/core/Mage/Checkout/Block/Multishipping/Overview.php
*
* @magentoDataFixture Mage/Sales/_files/quote.php
* @magentoDataFixture Mage/Customer/_files/customer.php
*/
public function testOverviewAction()
{
$quote = new Mage_Sales_Model_Quote();
$quote->load('test01', 'reserved_order_id');
Mage::getSingleton('Mage_Checkout_Model_Session')->setQuoteId($quote->getId());
$session = new Mage_Customer_Model_Session();
$session->login('customer@example.com', 'password');
$this->getRequest()->setPost('payment', array('method' => 'checkmo'));
$this->dispatch('checkout/multishipping/overview');
$html = $this->getResponse()->getBody();
$this->assertContains('<p>' . $quote->getPayment()->getMethodInstance()->getTitle() . '</p>', $html);
$this->assertContains('<span class="price">$10.00</span>', $html);
}
示例11: 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->setIncrementId($quote->getReservedOrderId())->setStoreId($quote->getStoreId())->setQuoteId($quote->getId());
Mage::helper('core')->copyFieldset('sales_convert_quote', 'to_order', $quote, $order);
if (!$quote->getCustomerId()) {
$order->setCustomerId(null);
}
//
// ->setRemoteIp($quote->getRemoteIp())
//
// /**
// * Customer data
// */
// ->setCustomerId($quote->getCustomerId())
// ->setCustomerEmail($quote->getCustomerEmail())
// ->setCustomerPrefix($quote->getCustomerPrefix())
// ->setCustomerFirstname($quote->getCustomerFirstname())
// ->setCustomerMiddlename($quote->getCustomerMiddlename())
// ->setCustomerLastname($quote->getCustomerLastname())
// ->setCustomerSuffix($quote->getCustomerSuffix())
// ->setCustomerGroupId($quote->getCustomerGroupId())
// ->setCustomerTaxClassId($quote->getCustomerTaxClassId())
// ->setCustomerNote($quote->getCustomerNote())
// ->setCustomerNoteNotify($quote->getCustomerNoteNotify())
// ->setCustomerIsGuest($quote->getCustomerIsGuest())
// ->setCustomerDob($quote->getCustomerDob())
//
// /**
// * Currency data
// */
// ->setBaseCurrencyCode($quote->getBaseCurrencyCode())
// ->setStoreCurrencyCode($quote->getStoreCurrencyCode())
// ->setOrderCurrencyCode($quote->getQuoteCurrencyCode())
// ->setStoreToBaseRate($quote->getStoreToBaseRate())
// ->setStoreToOrderRate($quote->getStoreToQuoteRate())
//
// /**
// * Another data
// */
// ->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;
}
示例12: getCustomerCart
/**
* Retrieve customer cart quote object model
*
* @return Mage_Sales_Model_Quote
*/
public function getCustomerCart()
{
if (!is_null($this->_cart)) {
return $this->_cart;
}
$this->_cart = Mage::getModel('sales/quote');
if ($this->getSession()->getCustomer()->getId()) {
$this->_cart->setStore($this->getSession()->getStore())->loadByCustomer($this->getSession()->getCustomer()->getId());
if (!$this->_cart->getId()) {
$this->_cart->assignCustomer($this->getSession()->getCustomer());
$this->_cart->save();
}
}
return $this->_cart;
}
示例13: getAlias
/**
* get alias or generate a new one
*
* alias has length 16 and consists of quote creation date, a separator,
* and the quote id to make sure we have the full quote id we shorten
* the creation date accordingly
*
* @param Mage_Sales_Model_Quote $quote
*
* @return string
*/
public function getAlias($quote)
{
$alias = $quote->getPayment()->getAdditionalInformation('alias');
if (0 == strlen($alias)) {
/* turn createdAt into format MMDDHHii */
$createdAt = substr(str_replace(array(':', '-', ' '), '', $quote->getCreatedAt()), 4, -2);
$quoteId = $quote->getId();
/* shorten createdAt, if we would exceed maximum length */
$maxAliasLength = 16;
$separator = '99';
$maxCreatedAtLength = $maxAliasLength - strlen($quoteId) - strlen($separator);
$alias = substr($createdAt, 0, $maxCreatedAtLength) . $separator . $quoteId;
}
if ($this->isAdminSession() && !strpos($alias, 'BE')) {
$alias = $alias . 'BE';
}
return $alias;
}
示例14: saveOrder
/**
* Place the order when customer returned from paypal
* Until this moment all quote data must be valid
*
* @return array
*/
public function saveOrder()
{
$this->_ignoreAddressValidation();
$order = Mage::getModel('sales/service_quote', $this->_quote)->submit();
$this->_quote->save();
/**
* Prepare session to success or cancellation page
*/
$quoteId = $this->_quote->getId();
$this->_getCheckoutSession()->setLastQuoteId($quoteId)->setLastSuccessQuoteId($quoteId)->setLastOrderId($order->getId())->setLastRealOrderId($order->getIncrementId());
if ($order->getState() == Mage_Sales_Model_Order::STATE_PROCESSING) {
try {
$order->sendNewOrderEmail();
} catch (Exception $e) {
Mage::logException($e);
}
}
return array();
}
示例15: _addCustomer
/**
* 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;
}