무료 배송을위한 합계를 기반으로 한 맞춤형 메시지
문제
는 고객이 자유 전달 임계 값 I.E.E.E.E.E.E.E.E.
에 가깝게 될 때 카트 페이지에 팝업 박스 또는 경고에 메시지를 표시 할 수 있습니다."£ 5를 보내고 무료 배송 자격을 얻으십시오"
해결책
자신의 모듈을 만듭니다.StackExchange_FreeShipping
라고 부르자
다음 파일이 필요합니다.
app/etc/modules/StackExchange_FreeShipping.xml
- 선언 파일
<?xml version="1.0"?>
<config>
<modules>
<StackExchange_FreeShipping>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Shipping />
</depends>
</StackExchange_FreeShipping>
</modules>
</config>
.
app/code/local/StackExchange/FreeShipping/etc/config.xml
- 구성 파일
<?xml version="1.0"?>
<config>
<modules>
<StackExchange_FreeShipping>
<version>0.0.1</version>
</StackExchange_FreeShipping>
</modules>
<global>
<helpers>
<stackexchange_freeshipping>
<class>StackExchange_FreeShipping_Helper</class>
</stackexchange_freeshipping>
</helpers>
<models>
<stackexchange_freeshipping>
<class>StackExchange_FreeShipping_Model</class>
</stackexchange_freeshipping>
</models>
</global>
<frontend>
<translate>
<modules>
<StackExchange_FreeShipping>
<files>
<default>StackExchange_FreeShipping.csv</default>
</files>
</StackExchange_FreeShipping>
</modules>
</translate>
<events>
<controller_action_predispatch_checkout_cart_index>
<observers>
<stackexchange_freeshipping>
<class>stackexchange_freeshipping/observer</class>
<method>checkFreeShipping</method>
</stackexchange_freeshipping>
</observers>
</controller_action_predispatch_checkout_cart_index>
</events>
</frontend>
</config>
.
app/code/local/StackExchange/FreeShipping/Model/Observer.php
- 무료 배송
<?php
class StackExchange_FreeShipping_Model_Observer
{
public function checkFreeShipping($observer)
{
//if free shipping is not enabled, do nothing
if (!Mage::getStoreConfig('carriers/freeshipping/active')) {
return $this;
}
$quote = Mage::getSingleton('checkout/session')->getQuote();
//if there are no products in the cart, again, do nothing
if (count($quote->getAllItems()) == 0 ){
return $this;
}
//get the quote subtotal
$subtotal = $quote->getSubtotal();
//get the free shipping
$freeShippingValue = Mage::getStoreConfig('carriers/freeshipping/free_shipping_subtotal');
//check if the cart is below the free shipping amount
if ($freeShippingValue > $subtotal) {
Mage::getSingleton('checkout/session')->addNotice(
Mage::helper('stackexchange_freeshipping')->__(
'Your cart has the has the value of %s. In order to get free shipping you need to order for %s more',
'<span style="color:green">'.Mage::helper('core')->currency($subtotal, true, false).'</span>',
'<span style="color:red">'.Mage::helper('core')->currency($freeShippingValue - $subtotal, true, false).'</span>'
)
);
}
}
}
.
app/locale/en_US/StackExchange_FreeShipping.csv
- 번역 파일입니다.가지고있는 모든 언어에 대해 추가 할 수 있습니다.
"Your cart has the has the value of %s. In order to get free shipping you need to order for %s more","Your cart has the has the value of %s. In order to get free shipping you need to order for %s more"
.
물론 다른 텍스트를 변경하십시오.
캐시를 청소하고 이동하십시오.
이제 장바구니에서보십시오.
Your cart has the has the value of 34$. In order to get free shipping you need to order for 15$ more.
. 다른 팁
@marius의 답변을 완료하면 헬퍼를 추가해야합니다. 그렇지 않으면
없이 오류가 발생합니다.앱 / 코드 / 로컬 / stackexchange / freeshipping / helper / data.php
<?php
class StackExchange_FreeShipping_Helper_Data extends Mage_Core_Helper_Abstract{
}
. 제휴하지 않습니다 magento.stackexchange