OpenCart VQMod Invalid Regex Error

241 Views Asked by At

I'm trying to add a bit of code after the checkout->confirm function. I'm trying to add it to all the payment gateways. The Regex is:

\$this->model_checkout_order->confirm.*\);$

And in the VqMod file:

<file name="catalog/controller/payment/*.php">
    <operation info="In ALL payment gateways, On order confirm, generate the file and upload it">
        <search position="after" error="log" regex="true"><![CDATA[\$this->model_checkout_order->confirm.*\);$]]></search>
        <add><![CDATA[
            //added code here...
        ]]></add>
    </operation>
</file>

However, it doesn't work and just leaves

INVALID REGEX ERROR - \$this->model_checkout_order->confirm.*\);$

In the vqmod.log file.

What have I missed?

1

There are 1 best solutions below

2
On BEST ANSWER

Regex values also need you to provide the delimiter of the regex, such as a ~

~\$this->model_checkout_order->confirm.*\);$~

you can optionally add the flags at the end for case insensitivity etc

EDIT

You can actually just do the same thing in your code without regex

file name="catalog/controller/payment/*.php">
    <operation info="In ALL payment gateways, On order confirm, generate the file and upload it">
        <search position="after" error="log"><![CDATA[$this->model_checkout_order->confirm(]]></search>
        <add><![CDATA[
            //added code here...
        ]]></add>
    </operation>
</file>