【问题标题】:hide the shipping steps from checkout隐藏结帐时的运输步骤
【发布时间】:2014-01-21 15:32:52
【问题描述】:

我安装了 Magento 1.8 CE 并希望在结帐时隐藏运输步骤,所有运输都是免费的,因为我们永远不会使用实际地址发送任何东西,所有东西都将通过电子邮件发送给客户。

查了很多帖子都是1.8之前的版本,1.8ce什么都没有

对此有什么帮助吗?管理员有什么配置吗?

【问题讨论】:

    标签: php magento checkout shipping magento-1.8


    【解决方案1】:

    设置:产品类型为:虚拟产品。这将关闭#3 运送信息和#4 运送方式。

    结帐流程将变为:

    1. 列表项
    2. 结账方式
    3. 帐单信息
    4. 付款信息
    5. 订单审核

    适用于版本 1.8 - 1.9 CE

    阅读 Magento 知识库:了解产品类型: http://www.magentocommerce.com/knowledge-base/categories/category/product-types

    【讨论】:

      【解决方案2】:

      要在结帐页面上隐藏送货方式步骤,您可以临时评论正在使用的默认 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;
          }
      

      一旦完成更改,请测试完整的订单流程,以查看所做的更改以消除运输步骤。

      【讨论】:

        【解决方案3】:

        请使用产品类型作为可下载产品,而不是简单产品或分组类型或使用 other.downloadable 产品默认隐藏运输方式和运输详细信息。

        【讨论】:

        • 如果他们的目录中有简单的产品怎么办?
        • 正如您在问题中所说的“所有运费都是免费的,因为我们永远不会使用实际地址发送任何东西,所有东西都将通过电子邮件发送给客户。”然后使用可下载的产品。如果您的购物车中有简单的产品,那么它将显示运输方式。
        猜你喜欢
        • 2013-09-14
        • 1970-01-01
        • 2012-08-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-06-15
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多