Search code examples
phpregexopencartvqmod

OpenCart VQMod Invalid Regex Error


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?


Solution

  • 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>