0

I want to place the code after the $order_product_id = $this->db->getLastId() which occur 2 times in order.php file. I want to place the code in both places. The OCMOD is placing the code as instructed but it is also adding the code third time and placing it in random place.

<file path="catalog/model/checkout/order.php">
    <operation>
        <search trim="true" index="0">
            <![CDATA[
             $order_product_id = $this->db->getLastId();
             ]]>
        </search>
        <add position="after">
            <![CDATA[
                if($product['variation_detail_id']){
            $this->db->query("INSERT INTO `oc_order_variation`( `order_id`, `order_product_id`, `product_variation_detail_id`) VALUES (".(int)$order_id.",".(int)$order_product_id.",".(int)$product['variation_detail_id'].")");
        }
            ]]>
        </add>
    </operation>

</file>

I have also tried using offset but it neglect the first occurrence and place the code in the second occurrence only. Is there a way to add the code in both places?

HDP
  • 4,005
  • 2
  • 36
  • 58

2 Answers2

0

Please try like as

"index=0,1,2"

I hope it will solve your problem.

LetsCMS Pvt Ltd
  • 634
  • 5
  • 7
0

Here, You have not need to add index="0"for that. please try following code.

<file path="catalog/model/checkout/order.php">
    <operation>
        <search trim="true">
            <![CDATA[
             $order_product_id = $this->db->getLastId();
             ]]>
        </search>
        <add position="after">
            <![CDATA[
                if($product['variation_detail_id']){
            $this->db->query("INSERT INTO `oc_order_variation`( `order_id`, `order_product_id`, `product_variation_detail_id`) VALUES (".(int)$order_id.",".(int)$order_product_id.",".(int)$product['variation_detail_id'].")");
        }
            ]]>
        </add>
    </operation>
</file>

You can find official OCMOD documentation Here

HDP
  • 4,005
  • 2
  • 36
  • 58