本文整理汇总了PHP中Mage_Sales_Model_Order::getStore方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order::getStore方法的具体用法?PHP Mage_Sales_Model_Order::getStore怎么用?PHP Mage_Sales_Model_Order::getStore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Order
的用法示例。
在下文中一共展示了Mage_Sales_Model_Order::getStore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filterValidForOrder
public function filterValidForOrder(Mage_Sales_Model_Order $order)
{
$this->addFieldToFilter('is_active', '1');
$this->addFieldToFilter('website_ids', ['finset' => $order->getStore()->getWebsiteId()]);
$this->addOrder('sort_order', 'DESC');
return $this;
}
示例2: _createCustomer
/**
* @param Mage_Sales_Model_Order $order
* @return int
*/
protected function _createCustomer(Mage_Sales_Model_Order $order)
{
/** @var $customer Mage_Customer_Model_Customer */
$customer = Mage::getModel('customer/customer')->setWebsiteId($order->getStore()->getWebsiteId())->loadByEmail($order->getCustomerEmail());
$customerGroupId = 1;
// @todo load general customer group ID?
if (!$customer->getId()) {
$customer->addData(array('prefix' => $order->getCustomerPrefix(), 'firstname' => $order->getCustomerFirstname(), 'middlename' => $order->getCustomerMiddlename(), 'lastname' => $order->getCustomerLastname(), 'suffix' => $order->getCustomerSuffix(), 'email' => $order->getCustomerEmail(), 'group_id' => $customerGroupId, 'taxvat' => $order->getCustomerTaxvat(), 'website_id' => $order->getStore()->getWebsiteId(), 'default_billing' => '_item1', 'default_shipping' => '_item2'));
// Billing Address
/** @var $billingAddress Mage_Sales_Model_Order_Address */
$billingAddress = $order->getBillingAddress();
/** @var $customerBillingAddress Mage_Customer_Model_Address */
$customerBillingAddress = Mage::getModel('customer/address');
$billingAddressArray = $billingAddress->toArray();
unset($billingAddressArray['entity_id']);
unset($billingAddressArray['parent_id']);
unset($billingAddressArray['customer_id']);
unset($billingAddressArray['customer_address_id']);
unset($billingAddressArray['quote_address_id']);
$customerBillingAddress->addData($billingAddressArray);
$customerBillingAddress->setPostIndex('_item1');
$customer->addAddress($customerBillingAddress);
// Shipping Address
/** @var $shippingAddress Mage_Sales_Model_Order_Address */
$shippingAddress = $order->getShippingAddress();
/** @var $customerShippingAddress Mage_Customer_Model_Address */
$customerShippingAddress = Mage::getModel('customer/address');
$shippingAddressArray = $shippingAddress->toArray();
unset($shippingAddressArray['entity_id']);
unset($shippingAddressArray['parent_id']);
unset($shippingAddressArray['customer_id']);
unset($shippingAddressArray['customer_address_id']);
unset($shippingAddressArray['quote_address_id']);
$customerShippingAddress->addData($shippingAddressArray);
$customerShippingAddress->setPostIndex('_item2');
$customer->addAddress($customerShippingAddress);
// Save the customer
$customer->setPassword($customer->generatePassword());
$customer->save();
}
// Link customer to order
$order->setCustomerId($customer->getId());
$order->setCustomerIsGuest(0);
$order->setCustomerGroupId($customerGroupId);
$order->save();
return $customer->getId();
}
示例3: generateOrderArray
public function generateOrderArray(Mage_Sales_Model_Order $order)
{
$array = array('@context' => 'http://schema.org', '@type' => 'Order', 'merchant' => array('@type' => 'Organization', 'name' => $order->getStore()->getFrontendName()), 'orderNumber' => $order->getIncrementId(), 'priceCurrency' => $order->getOrderCurrency()->toString(), 'price' => (string) number_format($order->getBaseTotalDue(), 2), 'acceptedOffer' => $this->generateAcceptedOfferArray($order));
if (!$order->getCustomerIsGuest()) {
$array['url'] = $this->getViewOrderUrl($order);
}
return $array;
}
示例4: canCancel
public function canCancel(Mage_Sales_Model_Order $order)
{
if ($order->getCustomerId() != Mage::getSingleton('customer/session')->getCustomerId()) {
return false;
}
if (!in_array($order->getState(), Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates(), $strict = true)) {
return false;
}
if (!$order->canCancel() || $order->hasInvoices() || $order->hasShipments()) {
return false;
}
if ($order->getState() == Mage_Sales_Model_Order::STATE_NEW && $this->canCancelNew($order->getStore())) {
return true;
}
if ($order->getState() == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT && $this->canCancelPending($order->getStore())) {
return true;
}
return false;
}
示例5: _getCustomerId
/**
* get an id for the customer
* @return string
*/
protected function _getCustomerId()
{
/** bool $isGuest */
$isGuest = !$this->_order->getCustomerId();
/** @var int $customerId */
$customerId = $this->_order->getCustomerId() ?: $this->_getGuestCustomerId();
/** @var mixed $store */
$store = $this->_order->getStore();
return $this->_helper->prefixCustomerId($customerId, $store, $isGuest);
}
示例6: canReorder
public function canReorder(Mage_Sales_Model_Order $order)
{
if (!$this->isAllowed($order->getStore())) {
return false;
}
if (Mage::getSingleton('Mage_Customer_Model_Session')->isLoggedIn()) {
return $order->canReorder();
} else {
return true;
}
}
示例7: _getPaymentBlockHtmlFrom
/**
* @param Mage_Sales_Model_Order $order
* @return string
*/
protected function _getPaymentBlockHtmlFrom(Mage_Sales_Model_Order $order)
{
$storeId = $order->getStore()->getStoreId();
try {
// Retrieve specified view block from appropriate design package (depends on emulated store)
$paymentBlock = Mage::helper('payment')->getInfoBlock($order->getPayment())->setIsSecureMode(true);
$paymentBlock->getMethod()->setStore($storeId);
$paymentBlockHtml = $paymentBlock->toHtml();
} catch (Exception $exception) {
throw $exception;
}
return $paymentBlockHtml;
}
示例8: sendEmailNotification
/**
* Sends notification mail for selected shipping rate
*
* The code for this functionality is based on Mage_Sales_Model_Order::sendNewOrderEmail()
*
* @param Mage_Sales_Model_Order $order
* @return boolean
* @throws Exception
* @see Mage_Sales_Model_Order
*/
public function sendEmailNotification($order)
{
if (strncmp($order->getShippingMethod(), 'shippingrates_', 14) != 0) {
return false;
}
$notificationMail = $order->getShippingCarrier()->getNotificationMail($order->getShippingMethod());
if (!strlen(trim($notificationMail))) {
return false;
}
$storeId = $order->getStore()->getId();
// Start store emulation process
$appEmulation = Mage::getSingleton('core/app_emulation');
$initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId);
try {
// Retrieve specified view block from appropriate design package (depends on emulated store)
$paymentBlock = Mage::helper('payment')->getInfoBlock($order->getPayment())->setIsSecureMode(true);
$paymentBlock->getMethod()->setStore($storeId);
$paymentBlockHtml = $paymentBlock->toHtml();
} catch (Exception $exception) {
// Stop store emulation process
$appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
throw $exception;
}
// Stop store emulation process
$appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
// Retrieve corresponding email template id and customer name
if ($order->getCustomerIsGuest()) {
$templateId = Mage::getStoreConfig(Mage_Sales_Model_Order::XML_PATH_EMAIL_GUEST_TEMPLATE, $storeId);
$customerName = $order->getBillingAddress()->getName();
} else {
$templateId = Mage::getStoreConfig(Mage_Sales_Model_Order::XML_PATH_EMAIL_TEMPLATE, $storeId);
$customerName = $order->getCustomerName();
}
$mailer = Mage::getModel('core/email_template_mailer');
$emailInfo = Mage::getModel('core/email_info');
$emailInfo->addTo($notificationMail);
$mailer->addEmailInfo($emailInfo);
// Set all required params and send emails
$mailer->setSender(Mage::getStoreConfig(Mage_Sales_Model_Order::XML_PATH_EMAIL_IDENTITY, $storeId));
$mailer->setStoreId($storeId);
$mailer->setTemplateId($templateId);
$mailer->setTemplateParams(array('order' => $order, 'billing' => $order->getBillingAddress(), 'payment_html' => $paymentBlockHtml));
$mailer->send();
return true;
}
示例9: getOrderDocCode
public function getOrderDocCode(Mage_Sales_Model_Order $order)
{
$prefix = trim($this->getConfig('order_prefix', $order->getStore()), self::DOC_CODE_SEPARATOR);
$prefix = (empty($prefix) ? 'O' : $prefix) . self::DOC_CODE_SEPARATOR;
if ($order->getIncrementId()) {
return $prefix . $order->getIncrementId();
} else {
return null;
}
}
示例10: _getWebsiteConfig
/**
* @param Mage_Sales_Model_Order $order
* @return mixed
*/
private function _getWebsiteConfig(Mage_Sales_Model_Order $order)
{
if (!isset($this->_configs[$order->getStore()->getWebsiteId()])) {
$config = Mage::app()->getWebsite($order->getStore()->getWebsiteId())->getConfig('aftership_options');
// object conversion to avoid config element object for easy comparing
$this->_configs[$order->getStore()->getWebsiteId()] = (object) (array) $config['messages'];
}
return $this->_configs[$order->getStore()->getWebsiteId()];
}
示例11: _addBuckarooFeeTaxInfoFromRequest
/**
* Add Buckaroo Payment fee tax info by recreating the tax request.
*
* @param Mage_Sales_Model_Order $order
* @param array $fullInfo
* @param Mage_Sales_Model_Order_Invoice|Mage_Sales_Model_Order_Creditmemo $source
*
* @return array
*/
protected function _addBuckarooFeeTaxInfoFromRequest($order, $fullInfo, $source)
{
$store = $order->getStore();
$taxCalculation = Mage::getSingleton('tax/calculation');
/**
* Recalculate the tax request.
*/
$customerTaxClass = $order->getCustomerTaxClassId();
$shippingAddress = $order->getShippingAddress();
$billingAddress = $order->getBillingAddress();
$codTaxClass = Mage::getStoreConfig(self::XPATH_BUCKAROO_FEE_TAX_CLASS, $store);
$taxRequest = $taxCalculation->getRateRequest($shippingAddress, $billingAddress, $customerTaxClass, $store);
$taxRequest->setProductClassId($codTaxClass);
/**
* If the tax request fails, there is nothing more we can do. This might occur, if the tax rules have been
* changed since this order was placed. Unfortunately there is nothing we can do about this.
*/
if (!$taxRequest) {
return $fullInfo;
}
/**
* Get the applied rates.
*/
$appliedRates = Mage::getSingleton('tax/calculation')->getAppliedRates($taxRequest);
if (!isset($appliedRates[0]['rates'][0]['title'])) {
return $fullInfo;
}
/**
* Get the tax title from the applied rates.
*/
$buckarooFeeTaxTitle = $appliedRates[0]['rates'][0]['title'];
/**
* Fo through all tax info entries and try to match the title.
*/
foreach ($fullInfo as $key => $taxInfo) {
if ($taxInfo['title'] == $buckarooFeeTaxTitle) {
/**
* Update the tax info entry with the COD fee tax.
*/
$fullInfo[$key]['tax_amount'] += $source->getBuckarooFeeTax();
$fullInfo[$key]['base_tax_amount'] += $source->getBaseBuckarooFeeTax();
break;
}
}
return $fullInfo;
}
示例12: _getBuckarooFeeTaxRequest
/**
* Get the tax request object for the current quote.
*
* @param Mage_Sales_Model_Order $order
*
* @return bool|Varien_Object
*/
protected function _getBuckarooFeeTaxRequest(Mage_Sales_Model_Order $order)
{
$store = $order->getStore();
$feeTaxClass = Mage::getStoreConfig(self::XPATH_BUCKAROO_TAX_CLASS, $store);
/**
* If no tax class is configured for the Buckaroo Payment fee, there is no tax to be calculated.
*/
if (!$feeTaxClass) {
return false;
}
$taxCalculation = $this->getTaxCalculation();
$customerTaxClass = $order->getCustomerTaxClassId();
$shippingAddress = $order->getShippingAddress();
$billingAddress = $order->getBillingAddress();
$request = $taxCalculation->getRateRequest($shippingAddress, $billingAddress, $customerTaxClass, $store);
$request->setProductClassId($feeTaxClass);
return $request;
}
示例13: __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);
//.........这里部分代码省略.........
示例14: salesOrderBeforeSave
/**
* Order validate before save
*
* @param Mage_Sales_Model_Order $model
* @return void
*/
public function salesOrderBeforeSave($model)
{
if (!$this->_role->hasWebsiteAccess($model->getStore()->getWebsiteId(), true)) {
Mage::throwException(Mage::helper('enterprise_admingws')->__('An order cannot be created in disallowed store.'));
}
}
示例15: sendOrderEmail
/**
* Send order notification email to vendor
* @param Mage_Sales_Model_Order $order
*/
public function sendOrderEmail(Mage_Sales_Model_Order $order, $type)
{
$types = array(Ced_CsMarketplace_Model_Vorders::ORDER_NEW_STATUS => self::XML_PATH_ORDER_NEW_EMAIL_TEMPLATE, Ced_CsMarketplace_Model_Vorders::ORDER_CANCEL_STATUS => self::XML_PATH_ORDER_CANCEL_EMAIL_TEMPLATE);
if (!isset($types[$type])) {
return;
}
$storeId = $order->getStore()->getId();
if ($type == Ced_CsMarketplace_Model_Vorders::ORDER_NEW_STATUS) {
if (!$this->canSendNewOrderEmail($storeId)) {
return;
}
}
if ($type == Ced_CsMarketplace_Model_Vorders::ORDER_CANCEL_STATUS) {
if (!$this->canSendCancelOrderEmail($storeId)) {
return;
}
}
$vendorIds = array();
foreach ($order->getAllItems() as $item) {
if (!in_array($item->getVendorId(), $vendorIds)) {
$vendorIds[] = $item->getVendorId();
}
}
if ($type == Ced_CsMarketplace_Model_Vorders::ORDER_CANCEL_STATUS) {
// Start store emulation process
$storeId = Mage::app()->getStore()->getId();
$appEmulation = Mage::getSingleton('core/app_emulation');
$initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId);
}
try {
// Retrieve specified view block from appropriate design package (depends on emulated store)
$paymentBlock = Mage::helper('payment')->getInfoBlock($order->getPayment())->setIsSecureMode(true);
$paymentBlock->getMethod()->setStore($storeId);
$paymentBlockHtml = $paymentBlock->toHtml();
} catch (Exception $exception) {
// Stop store emulation process
if ($type == Ced_CsMarketplace_Model_Vorders::ORDER_CANCEL_STATUS) {
$appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
}
throw $exception;
}
foreach ($vendorIds as $vendorId) {
$vendor = Mage::getModel('csmarketplace/vendor')->load($vendorId);
if (!$vendor->getId()) {
continue;
}
$vorder = Mage::getModel('csmarketplace/vorders')->loadByField(array('order_id', 'vendor_id'), array($order->getIncrementId(), $vendorId));
if (Mage::registry('current_order') != '') {
Mage::unregister('current_order');
}
if (Mage::registry('current_vorder') != '') {
Mage::unregister('current_vorder');
}
Mage::register('current_order', $order);
Mage::register('current_vorder', $vorder);
$this->_sendEmailTemplate($types[$type], self::XML_PATH_ORDER_EMAIL_IDENTITY, array('vendor' => $vendor, 'order' => $order, 'billing' => $order->getBillingAddress(), 'payment_html' => $paymentBlockHtml), null);
}
if ($type == Ced_CsMarketplace_Model_Vorders::ORDER_CANCEL_STATUS) {
// Stop store emulation process
$appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
}
}