Post by AndrewCarsten » Mon May 27, 2024 8:40 am

I want to convert a payment extension from version 3.0 to version 2.3.0.2. I used a web converter to change the Twig files to TPL files and placed them in the appropriate folder, but it didn't work. This extension is for a credit card payment method.

I think the folder paths might be different between the two versions. I can compare the two versions to find the differences.

What else should I consider? Is the web converter a reliable source?

Learning everytime ! download lagu


User avatar
Newbie

Posts

Joined
Mon May 27, 2024 8:33 am

Post by softmonke » Mon May 27, 2024 5:46 pm

For directory paths, both OC 2.3 and OC 3 should be the same for payment methods - which should be in "extension/payment", so in admin, it would be "admin/controller/extension/payment/payment_name.php" and for the frontend, it would be "catalog/controller/extension/payment/payment_name.php". Same goes for language, view, model, etc.

Usually, when I convert extensions from OC 3 to OC 2.3, I perform a manual conversion from .twig to .tpl as I find that it saves me more time overall. Online converters can be inaccurate and can mess up the template code and you'll probably still need to manually go through the template file to make sure it's error-free - so you might as well perform a manual conversion in one go instead. It's quite simple to convert from .twig to .tpl: you can do a mass-replace for "{{ " (including the space after "{{") to "<?php echo $" and then " }}" (also including the space before "}}") to "; ?>", and then search for "{%" as this is used for for-loops, if-else conditions, declaring of variables, etc. and replace them with PHP code. For arrays, you will have to make sure that the correct format is used because in .twig, both '{{ array.key }}' and '{{ array["key"] }}' should work but in .tpl, it should be '<?php echo $array["key"]; ?>'.

Other than that, off the top of my head, there are some naming differences between the two version. In OC3, extension fields are prepended with the extension type - taking PayPal Standard payment method as an example, in OC2.3, the fields are named "pp_standard_xxx" while in OC3, the fields are prepended with "payment" so it becomes "payment_pp_standard_xxx". But I believe this shouldn't matter.

Anyway, maybe you can provide more information on how is it not working, such as any errors in your error logs or if there are any errors displayed, screenshots etc.

Reach out to us at hello@softmonke.com for your OpenCart web development needs.


User avatar
Active Member

Posts

Joined
Tue May 23, 2023 4:42 am

Who is online

Users browsing this forum: No registered users and 4 guests