【问题标题】:Hide Other Shipping (if free shipping active) plus also hide free shipping if active for a customer Group隐藏其他运费(如果免费送货有效)加上如果对客户组有效,还隐藏免费送货
【发布时间】:2019-02-28 00:03:43
【问题描述】:

Opencart 版本 2.3.0.2 - 当前使用 Vqmod(如下)在免费送货活动时隐藏其他送货。我希望对其进行调整以隐藏特定客户组 = '2" 的免费送货(即批发客户不会看到\被允许免费送货)。

<file path="catalog/model/extension/shipping/*.php">
<operation error="skip">
<search><![CDATA[if ($status) {]]></search>
<add position="before"><![CDATA[
if (get_class($this)!='ModelExtensionShippingFree') {
if (($this->config->get('free_status') == 1) && (float)$this->cart->getTotal() >= $this->config->get('free_total')) {
$status = false;
}
}
]]></add>

【问题讨论】:

  • 你可以使用这个免费的扩展:opencart.com/index.php?route=marketplace/extension/…
  • @KB我发布的代码有效地完成了免费扩展的作用,我正在寻找一种方法让它只适用于默认客户(组 ID = 1)而不是批发客户(组 ID = 2)
  • 对于您的运输条件后的客户组添加此条件:if ($this-&gt;session-&gt;data['customer_group_id'] == 1) { $status = true; } else { $status = false; }
  • @K.B.不幸的是,在这种情况下,您的建议不起作用
  • @K.B.谢谢你为我指出了正确的方向,使用 elseif 设法到达那里

标签: opencart opencart2.3 vqmod


【解决方案1】:

我没有太多使用 opencart 的经验,但 AFAIK 你不需要为 opencart v2.3 或更高版本使用 vqmod。此外,它是性能瓶颈和不可预测的。

ControllerCheckoutShippingMethod [catalog/controller/checkout/shipping_method.php] 类的index 方法负责生成所有运输方法并将它们全部放入会话中。 Opencart 允许我们在这个索引方法调用之后放置一个事件并修改最终输出。

Create a moduleinstall 方法中包含以下内容,以及您想在其中放入的任何其他内容:

<?php
// admin/controller/extensions/module/mymodule.php
public function install() {
 $this->load->model('extension/event');
 $this->model_extension_event->addEvent(
      'my_custom_module',
      'catalog/controller/checkout/shipping_method/after', // add event after shipping_method index call
      'extension/module/mymodule/eventAfterSM' // your module file (mymodule.php) with eventAfterSM method in it
 );
}

// catalog/controller/extension/module/mymodule.php
public function eventAfterSM() {
  // this method will be called right after `ControllerCheckoutShippingMethod`->`index`
  // copy and paste the entire index method code in here and modify accordingly
  // and finally set the modified data
  $this->response->setOutput($this->load->view('checkout/payment_method', $data));
}

【讨论】:

  • 很有趣 - 虽然如果可能的话更喜欢使用 vqmod
猜你喜欢
  • 2020-11-05
  • 2016-11-11
  • 2015-08-14
  • 1970-01-01
  • 2018-08-09
  • 2021-05-29
  • 2014-01-06
  • 2020-06-22
相关资源
最近更新 更多