本文整理汇总了PHP中Mage_Sales_Model_Quote::getCustomerGroupId方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Quote::getCustomerGroupId方法的具体用法?PHP Mage_Sales_Model_Quote::getCustomerGroupId怎么用?PHP Mage_Sales_Model_Quote::getCustomerGroupId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Quote
的用法示例。
在下文中一共展示了Mage_Sales_Model_Quote::getCustomerGroupId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: getRules
/**
* Return the correct rule set
*
* @param Mage_Sales_Model_Quote $quote
* @param bool $forceReload
*
* @return Mage_SalesRule_Model_Rule[]
*/
public function getRules(Mage_Sales_Model_Quote $quote, $forceReload = false)
{
$websiteId = intval($quote->getStore()->getWebsiteId());
$customerGroupId = intval($quote->getCustomerGroupId());
$couponCode = trim($quote->getCouponCode());
$key = $websiteId . '_' . $customerGroupId . '_' . $couponCode;
if ($forceReload) {
unset($this->rules[$key]);
}
if (!isset($this->rules[$key])) {
/** @var Mage_SalesRule_Model_Resource_Rule_Collection $rules */
$rules = Mage::getResourceModel('salesrule/rule_collection');
$rules->setValidationFilter($websiteId, $customerGroupId, $couponCode);
$this->rules[$key] = $rules->getItems();
}
return $this->rules[$key];
}
示例3: _getCustomerTaxClass
/**
* Retreive customer tax class from quote
*
* @param Mage_Sales_Model_Quote $quote
* @return int
*/
protected function _getCustomerTaxClass(Mage_Sales_Model_Quote $quote)
{
$customerGroup = $quote->getCustomerGroupId();
if (!$customerGroup) {
$customerGroup = Mage::getStoreConfig('customer/create_account/default_group', $quote->getStoreId());
}
return Mage::getModel('customer/group')->load($customerGroup)->getTaxClassId();
}
示例4: _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;
}