我想使用 OCMOD 替换行
我正在使用下面的代码替换文件admin/model/sale/customer.php中的行
<file path="admin/model/sale/customer.php" error="log">
<operation>
<search><![CDATA[ $this->load->model('setting/store'); ]]></search>
<add position="before"><![CDATA[
if($this->isFront==true) {
$this->load->adminmodel('setting/store');
} else {
$this->load->model('setting/store');
}
]]></add>
</operation>
</file>
搜索行在$this->load->model('setting/store');
文件中重复 3 次。
问题是当我使用上面的代码时,它会意外替换该行。它将代码添加到函数附近的某个位置,这会导致修改时出现语法错误。替换后的示例:
.....
.....
public function addReward($customer_id,
if($this->isFront==true) {
$this->load->adminmodel('setting/store');
} else {
$this->load->model('setting/store');
}
$this->load->model('setting/store');der_id = 0) {
$customer_info = $this->getCustomer($customer_id);
if ($customer_info) {
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_reward SET customer_id = '" . (int)$customer_id . "', order_id = '" . (int)$order_id . "', points = '" . (int)$points . "', description = '" . $this->db->escape($description) . "', date_added = NOW()");
$this->load->language('mail/customer');
.....
.....
正确更换它的解决方案是什么?我不介意解决方案是否仅在addReward函数中替换。此外,我对之前、之后、替换和正则表达式都很好。
我想这可能是OCMOD的问题。