本文整理汇总了PHP中Mage_Sales_Model_Order::getCouponCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order::getCouponCode方法的具体用法?PHP Mage_Sales_Model_Order::getCouponCode怎么用?PHP Mage_Sales_Model_Order::getCouponCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Order
的用法示例。
在下文中一共展示了Mage_Sales_Model_Order::getCouponCode方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toQuote
/**
* Converting order object to quote object
*
* @param Mage_Sales_Model_Order $order
* @return Mage_Sales_Model_Quote
*/
public function toQuote(Mage_Sales_Model_Order $order, $quote = null)
{
if (!$quote instanceof Mage_Sales_Model_Quote) {
$quote = Mage::getModel('sales/quote');
}
$quote->setStoreId($order->getStoreId())->setOrderId($order->getId())->setCustomerId($order->getCustomerId())->setCustomerEmail($order->getCustomerEmail())->setCustomerGroupId($order->getCustomerGroupId())->setCustomerTaxClassId($order->getCustomerTaxClassId())->setCustomerIsGuest($order->getCustomerIsGuest())->setBaseCurrencyCode($order->getBaseCurrencyCode())->setStoreCurrencyCode($order->getStoreCurrencyCode())->setQuoteCurrencyCode($order->getOrderCurrencyCode())->setStoreToBaseRate($order->getStoreToBaseRate())->setStoreToQuoteRate($order->getStoreToOrderRate())->setGrandTotal($order->getGrandTotal())->setBaseGrandTotal($order->getBaseGrandTotal())->setCouponCode($order->getCouponCode())->setGiftcertCode($order->getGiftcertCode())->setAppliedRuleIds($order->getAppliedRuleIds())->collectTotals();
Mage::dispatchEvent('sales_convert_order_to_quote', array('order' => $order, 'quote' => $quote));
return $quote;
}
示例2: getScript
public function getScript()
{
$request = Mage::app()->getRequest();
$module = $request->getModuleName();
$controller = $request->getControllerName();
$action = $request->getActionName();
$flag = false;
$currency = Mage::app()->getStore()->getCurrentCurrencyCode();
$script = "<script>var apiKey = '" . $this->getKey() . "';</script>" . "\n";
if ($module == 'checkout' && $controller == 'onestep' && $action == 'success' || $module == 'checkout' && $controller == 'onepage' && $action == 'success' || $module == 'securecheckout' && $controller == 'index' && $action == 'success' || $module == 'customdownloadable' && $controller == 'onepage' && $action == 'success' || $module == 'onepagecheckout' && $controller == 'index' && $action == 'success' || $module == 'onestepcheckout' && $controller == 'index' && $action == 'success') {
$order = new Mage_Sales_Model_Order();
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order->loadByIncrementId($orderId);
// Load order details
$order_total = round($order->getGrandTotal(), 2);
// Get grand total
$order_coupon = $order->getCouponCode();
// Get coupon used
$items = $order->getAllItems();
// Get items info
$cartInfo = array();
// Convert object to string
foreach ($items as $item) {
$product = Mage::getModel('catalog/product')->load($item->getProductId());
$name = $item->getName();
$qty = $item->getQtyToInvoice();
$cartInfo[] = array('id' => $item->getProductId(), 'name' => $name, 'quantity' => $qty);
}
$cartInfoString = serialize($cartInfo);
$cartInfoString = addcslashes($cartInfoString, "'");
$order_name = $order->getCustomerName();
// Get customer's name
$order_email = $order->getCustomerEmail();
// Get customer's email id
// Call invoiceRefiral function
$scriptAppend = "<script>whenAvailable('invoiceRefiral',function(){invoiceRefiral('{$order_total}','{$order_total}','{$order_coupon}','{$cartInfoString}','{$order_name}','{$order_email}','{$orderId}', '{$currency}')});</script>" . "\n";
if ($this->debug()) {
$scriptAppend .= "<script>console.log('Module: " . $module . ", Controller: " . $controller . ", Action: " . $action . "');</script>";
$scriptAppend .= "<script>console.log('Total: " . $order_total . ", Coupon: " . $order_coupon . ", Cart: " . $cartInfoString . ", Name: " . $order_name . ", Email: " . $order_email . ", Id: " . $orderId . ", Currency: " . $currency . "');</script>";
}
$script .= '<script>var showButton = false;</script>' . "\n";
} else {
if ($this->debug()) {
$scriptAppend = "<script>console.log('Module: " . $module . ", Controller: " . $controller . ", Action: " . $action . "');</script>";
} else {
$scriptAppend = '';
}
$script .= '<script>var showButton = true;</script>' . "\n";
}
$script .= '<script type="text/javascript">(function e(){var e=document.createElement("script");e.type="text/javascript",e.async=true,e.src="//rfer.co/api/v1/js/all.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})();</script>' . "\n";
return $script . $scriptAppend;
}
示例3: setOrderData
/**
* set the order information
*
* @param Mage_Sales_Model_Order $orderData
*/
public function setOrderData(Mage_Sales_Model_Order $orderData)
{
$this->id = (string) $orderData->getIncrementId();
$this->quote_id = (string) $orderData->getQuoteId();
$this->email = (string) $orderData->getCustomerEmail();
$this->store_name = (string) $orderData->getStoreName();
$created_at = new Zend_Date($orderData->getCreatedAt(), Zend_Date::ISO_8601);
$this->purchase_date = $created_at->toString(Zend_Date::ISO_8601);
$this->delivery_method = $orderData->getShippingDescription();
$this->delivery_total = (double) number_format($orderData->getShippingAmount(), 2, '.', '');
$this->currency = $orderData->getStoreCurrencyCode();
if ($payment = $orderData->getPayment()) {
$this->payment = $payment->getMethodInstance()->getTitle();
}
$this->couponCode = (string) $orderData->getCouponCode();
//set order custom attributes
$this->_setOrderCustomAttributes($orderData);
//billing
$this->_setBillingData($orderData);
//shipping
$this->_setShippingData($orderData);
//order items
$this->_setOrderItems($orderData);
//sales data
$this->order_subtotal = (double) number_format($orderData->getData('subtotal'), 2, '.', '');
$this->discount_ammount = (double) number_format($orderData->getData('discount_amount'), 2, '.', '');
$orderTotal = abs($orderData->getData('grand_total') - $orderData->getTotalRefunded());
$this->order_total = (double) number_format($orderTotal, 2, '.', '');
$this->order_status = (string) $orderData->getStatus();
}
示例4: _buildCommonParams
/**
* build common params array
* @param Mage_Sales_Model_Order $order
* @return array
*/
protected function _buildCommonParams(Mage_Sales_Model_Order $order)
{
$params = array(static::KEY_PID => Mage::helper('eems_affiliate/config')->getProgramId(), static::KEY_OID => $order->getIncrementId());
$couponCode = trim($order->getCouponCode());
return $couponCode !== '' ? array_merge($params, array(static::KEY_PROMOCODE => $couponCode)) : $params;
}
示例5: _getCouponsFormatted
/**
* @param Mage_Sales_Model_Order $order
* @return array
*/
protected function _getCouponsFormatted($order)
{
$result = array();
if ($order->getCouponCode()) {
if (Mage::helper("shopgate/config")->getIsMagentoVersionLower1410()) {
$mageRule = Mage::getModel('salesrule/rule')->load($order->getCouponCode(), 'coupon_code');
$mageCoupon = $mageRule;
} else {
$mageCoupon = Mage::getModel('salesrule/coupon')->load($order->getCouponCode(), 'code');
$mageRule = Mage::getModel('salesrule/rule')->load($mageCoupon->getRuleId());
}
$externalCoupon = new ShopgateExternalCoupon();
$couponInfo = array();
$couponInfo["coupon_id"] = $mageCoupon->getId();
$couponInfo["rule_id"] = $mageRule->getId();
$externalCoupon->setCode($order->getCouponCode());
$externalCoupon->setCurrency($order->getOrderCurrencyCode());
$externalCoupon->setName($mageRule->getName());
$externalCoupon->setDescription($mageRule->getDescription());
$externalCoupon->setInternalInfo($this->_getConfig()->jsonEncode($couponInfo));
$externalCoupon->setAmount($order->getDiscountAmount());
array_push($result, $externalCoupon);
}
return $result;
}
示例6: refillCart
/**
* refill cart
*
* @param Mage_Sales_Model_Order $order
*
* @return void
*/
public function refillCart($order)
{
// add items
$cart = Mage::getSingleton('checkout/cart');
if (0 < $cart->getQuote()->getItemsCollection()->count()) {
//cart is not empty, so refilling it is not required
return;
}
foreach ($order->getItemsCollection() as $item) {
try {
$cart->addOrderItem($item);
} catch (Exception $e) {
Mage::logException($e);
}
}
$cart->save();
// add coupon code
$coupon = $order->getCouponCode();
$session = Mage::getSingleton('checkout/session');
if (false == is_null($coupon)) {
$session->getQuote()->setCouponCode($coupon)->save();
}
}
示例7: refillCart
/**
* refill cart
*
* @param Mage_Sales_Model_Order $order
*
* @return void
*/
public function refillCart($order)
{
// add items
$cart = Mage::getSingleton('checkout/cart');
foreach ($order->getItemsCollection() as $item) {
try {
$cart->addOrderItem($item);
} catch (Exception $e) {
Mage::log($e->getMessage());
}
}
$cart->save();
// add coupon code
$coupon = $order->getCouponCode();
$session = Mage::getSingleton('checkout/session');
if (false == is_null($coupon)) {
$session->getQuote()->setCouponCode($coupon)->save();
}
}
示例8: __construct
/**
* set the order information
* @param Mage_Sales_Model_Order $orderData
*/
public function __construct(Mage_Sales_Model_Order $orderData)
{
$customerModel = Mage::getModel('customer/customer');
$customerModel->load($orderData->getCustomerId());
$this->id = $orderData->getIncrementId();
$this->quote_id = $orderData->getQuoteId();
$this->email = $orderData->getCustomerEmail();
$this->store_name = $orderData->getStoreName();
$created_at = new Zend_Date($orderData->getCreatedAt(), Zend_Date::ISO_8601);
$this->purchase_date = $created_at->toString(Zend_Date::ISO_8601);
$this->delivery_method = $orderData->getShippingDescription();
$this->delivery_total = $orderData->getShippingAmount();
$this->currency = $orderData->getStoreCurrencyCode();
if ($payment = $orderData->getPayment()) {
$this->payment = $payment->getMethodInstance()->getTitle();
}
$this->couponCode = $orderData->getCouponCode();
/**
* custom order attributes
*/
$helper = Mage::helper('ddg');
$website = Mage::app()->getStore($orderData->getStore())->getWebsite();
$customAttributes = $helper->getConfigSelectedCustomOrderAttributes($website);
if ($customAttributes) {
$fields = Mage::getResourceModel('ddg_automation/order')->getOrderTableDescription();
foreach ($customAttributes as $customAttribute) {
if (isset($fields[$customAttribute])) {
$field = $fields[$customAttribute];
$value = $this->_getCustomAttributeValue($field, $orderData);
if ($value) {
$this->_assignCustom($field, $value);
}
}
}
}
/**
* Billing address.
*/
if ($orderData->getBillingAddress()) {
$billingData = $orderData->getBillingAddress()->getData();
$this->billing_address = array('billing_address_1' => $this->_getStreet($billingData['street'], 1), 'billing_address_2' => $this->_getStreet($billingData['street'], 2), 'billing_city' => $billingData['city'], 'billing_region' => $billingData['region'], 'billing_country' => $billingData['country_id'], 'billing_postcode' => $billingData['postcode']);
}
/**
* Shipping address.
*/
if ($orderData->getShippingAddress()) {
$shippingData = $orderData->getShippingAddress()->getData();
$this->delivery_address = array('delivery_address_1' => $this->_getStreet($shippingData['street'], 1), 'delivery_address_2' => $this->_getStreet($shippingData['street'], 2), 'delivery_city' => $shippingData['city'], 'delivery_region' => $shippingData['region'], 'delivery_country' => $shippingData['country_id'], 'delivery_postcode' => $shippingData['postcode']);
}
$syncCustomOption = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_ORDER_PRODUCT_CUSTOM_OPTIONS, $website);
/**
* Order items.
* @var Mage_Sales_Model_Order_Item $productItem
*/
foreach ($orderData->getAllItems() as $productItem) {
//product custom options
$customOptions = array();
if ($syncCustomOption) {
$customOptions = $this->_getOrderItemOptions($productItem);
}
$product = $productItem->getProduct();
if ($product) {
// category names
$categoryCollection = $product->getCategoryCollection()->addAttributeToSelect('name');
$productCat = array();
foreach ($categoryCollection as $cat) {
$categories = array();
$categories[] = $cat->getName();
$productCat[]['Name'] = substr(implode(', ', $categories), 0, 244);
}
$attributes = array();
//selected attributes from config
$configAttributes = Mage::helper('ddg')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_ORDER_PRODUCT_ATTRIBUTES, $orderData->getStore()->getWebsite());
if ($configAttributes) {
$configAttributes = explode(',', $configAttributes);
//attributes from attribute set
$attributesFromAttributeSet = $this->_getAttributesArray($product->getAttributeSetId());
foreach ($configAttributes as $attribute_code) {
//if config attribute is in attribute set
if (in_array($attribute_code, $attributesFromAttributeSet)) {
//attribute input type
$inputType = $product->getResource()->getAttribute($attribute_code)->getFrontend()->getInputType();
//fetch attribute value from product depending on input type
switch ($inputType) {
case 'multiselect':
case 'select':
case 'dropdown':
$value = $product->getAttributeText($attribute_code);
break;
default:
$value = $product->getData($attribute_code);
break;
}
if ($value) {
// check limit on text and assign value to array
$attributes[][$attribute_code] = $this->_limitLength($value);
//.........这里部分代码省略.........
示例9: getCouponCodesFromOrder
/**
* Get coupon codes from order
* @param Mage_Sales_Model_Order
* @return array
*/
public function getCouponCodesFromOrder(Mage_Sales_Model_Order $order)
{
$couponCode = $order->getCouponCode();
return $this->getCouponCodes($couponCode);
}