我安装了 Magento 1.8 CE 并希望在结帐时隐藏运输步骤,所有运输都是免费的,因为我们永远不会使用物理地址发送任何东西,所有东西都将通过电子邮件发送给客户。
我查了很多1.8之前版本的帖子,1.8ce什么都没有
有什么帮助吗?是否有通过管理员进行的任何配置?
我安装了 Magento 1.8 CE 并希望在结帐时隐藏运输步骤,所有运输都是免费的,因为我们永远不会使用物理地址发送任何东西,所有东西都将通过电子邮件发送给客户。
我查了很多1.8之前版本的帖子,1.8ce什么都没有
有什么帮助吗?是否有通过管理员进行的任何配置?
要在结帐页面上隐藏运输方式步骤,您可以临时评论正在使用的默认 Magento 功能并使用修改后的功能,如下所示。如果解决方案对您可行,那么只需注释掉代码并将更改粘贴到特定函数中。
转到 app/code/core/Mage/Checkout/Model/Type/Onepage.php
public function saveShippingMethod($shippingMethod)
{
if (empty($shippingMethod)) {
$shippingMethod = 'freeshipping_freeshipping';
//return array('error' => -1, 'message' => Mage::helper('checkout')->__('Invalid shipping method.'));
}
/*$rate = $this->getQuote()->getShippingAddress()->getShippingRateByCode($shippingMethod);
if (!$rate) {
return array('error' => -1, 'message' => Mage::helper('checkout')->__('Invalid shipping method.'));
}*/
$this->getQuote()->getShippingAddress()
->setShippingMethod($shippingMethod);
$this->getCheckout()
->setStepData('shipping_method', 'complete', true)
->setStepData('payment', 'allow', true);
return array();
}
转到 app/code/core/Mage/Checkout/controllers/OnepageController.php
public function saveBillingAction()
{
if ($this->_expireAjax()) {
return;
}
if ($this->getRequest()->isPost()) {
$data = $this->getRequest()->getPost('billing', array());
$customerAddressId = $this->getRequest()->getPost('billing_address_id', false);
if (isset($data['email'])) {
$data['email'] = trim($data['email']);
}
$result = $this->getOnepage()->saveBilling($data, $customerAddressId);
if (!isset($result['error'])) {
$method = 'freeshipping_freeshipping';
$result = $this->getOnepage()->saveShippingMethod($method);
Mage::getSingleton('checkout/type_onepage')->getQuote()->getShippingAddress()-> setShippingMethod($method)->save();
}
if (!isset($result['error'])) {
if ($this->getOnepage()->getQuote()->isVirtual()) {
$result['goto_section'] = 'payment';
$result['update_section'] = array(
'name' => 'payment-method',
'html' => $this->_getPaymentMethodsHtml()
);
/*} elseif (isset($data['use_for_shipping']) && $data['use_for_shipping'] == 1) {
$result['goto_section'] = 'shipping_method';
$result['update_section'] = array(
'name' => 'shipping-method',
'html' => $this->_getShippingMethodsHtml()
);
$result['allow_sections'] = array('shipping');
$result['duplicateBillingInfo'] = 'true';
}*/
}elseif (isset($data['use_for_shipping']) && $data['use_for_shipping'] == 1) {
$result['goto_section'] = 'payment';
$result['update_section'] = array(
'name' => 'payment-method',
'html' => $this->_getPaymentMethodsHtml()
);
}else {
$result['goto_section'] = 'shipping';
}
}
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}
public function saveShippingAction()
{
if ($this->_expireAjax()) {
return;
}
if ($this->getRequest()->isPost()) {
$data = $this->getRequest()->getPost('shipping', array());
$customerAddressId = $this->getRequest()->getPost('shipping_address_id', false);
$result = $this->getOnepage()->saveShipping($data, $customerAddressId);
/*if (!isset($result['error'])) {
$result['goto_section'] = 'shipping_method';
$result['update_section'] = array(
'name' => 'shipping-method',
'html' => $this->_getShippingMethodsHtml()
);
}*/
if (!isset($result['error'])) {
$result['goto_section'] = 'payment';
$result['update_section'] = array(
'name' => 'payment-method',
'html' => $this->_getPaymentMethodsHtml()
);
}
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}
转到 app\code\core\Mage\Checkout\Block\Onepage.php
public function getSteps()
{
$steps = array();
$stepCodes = $this->_getStepCodes();
unset($stepCodes[2]);
unset($stepCodes[3]);
if ($this->isCustomerLoggedIn()) {
$stepCodes = array_diff($stepCodes, array('login'));
}
foreach ($stepCodes as $step) {
$steps[$step] = $this->getCheckout()->getStepData($step);
}
return $steps;
}
转到 app\design\frontend\default\default\template\checkout\onepage\progress.phtml 注释下面的代码
<?php echo $this->getChildHtml('shipping.progress') ?>
<?php echo $this->getChildHtml('shippingmethod.progress') ?>
转到 app/code/core/Mage/Sales/Model/Service/Quote.php
protected function _validate()
{
if (!$this->getQuote()->isVirtual()) {
$address = $this->getQuote()->getShippingAddress();
$addressValidation = $address->validate();
if ($addressValidation !== true) {
Mage::throwException(
Mage::helper('sales')->__('Please check shipping address information. %s', implode(' ', $addressValidation))
);
}
/*$method= $address->getShippingMethod();
$rate = $address->getShippingRateByCode($method);
if (!$this->getQuote()->isVirtual() && (!$method || !$rate)) {
Mage::throwException(Mage::helper('sales')->__('Please specify a shipping method.'));
}*/
}
$addressValidation = $this->getQuote()->getBillingAddress()->validate();
if ($addressValidation !== true) {
Mage::throwException(
Mage::helper('sales')->__('Please check billing address information. %s', implode(' ', $addressValidation))
);
}
if (!($this->getQuote()->getPayment()->getMethod())) {
Mage::throwException(Mage::helper('sales')->__('Please select a valid payment method.'));
}
return $this;
}
aove 更改完成后,请测试完整的订单流程,以查看所做的更改以消除运输步骤。
请使用产品类型作为可下载产品,而不是简单产品或分组类型或使用 other.downloadable 产品默认隐藏运输方式和运输详细信息。
设置:产品类型为:虚拟产品。这将关闭#3 Shipping Information & #4 Shipping Method。
结帐流程将变为:
适用于版本 1.8 - 1.9 CE
阅读 Magento 知识库:了解产品类型: http: //www.magentocommerce.com/knowledge-base/categories/category/product-types