我安装了Magento 1.8 CE并希望隐藏结账时的运输步骤,所有运费都是免费的,因为我们绝不会使用实际地址发送任何内容,所有内容都将通过电子邮件发送给客户。
我已经检查过很多1.8之前版本的帖子,而且1.8ce
没有对此有何帮助?是否通过管理员进行任何配置?
答案 0 :(得分:1)
要隐藏结帐页面上的送货方法步骤,您可以临时评论正在使用的默认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更改后,请测试完整的订单流程,以便查看所做的更改以消除运输步骤。
答案 1 :(得分:0)
请使用产品类型作为可下载产品,而不是简单产品或分组类型或使用other.downloadable产品默认隐藏运输方式和运输详情。
答案 2 :(得分:0)
设置:产品类型为:虚拟产品。这将关闭#3运输信息&amp; #4送货方式。
结帐流程将变为:
适用于版本1.8 - 1.9 CE
阅读Magento知识库:了解产品类型: http://www.magentocommerce.com/knowledge-base/categories/category/product-types