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.

Check out our ever-growing list of extension for OpenCart: https://www.opencart.com/index.php?rout ... =softmonke.
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


Post by rory586 » Fri Jul 19, 2024 7:13 pm

Hello,
Converting a payment extension from OpenCart 3.0 to 2.3.0.2 can be tricky! Here's the breakdown:
The Problem:
  • Web converters likely won't do the job perfectly.
  • Folder paths, code structure, and how the extension interacts with OpenCart might be different.
What to Consider:
  • Folder Paths: Double-check if file paths have changed between versions. Manually move files to the correct locations in OpenCart 2.3.0.2.
  • Code Changes: Be prepared to edit the code itself. Differences in functions, variables, and how things connect might require manual adjustments.
  • Payment Gateway Integration: The way the extension talks to your payment gateway might need tweaks for the older version.
Skip the Web Converter:
  • Web converters are a shortcut, but they often miss important details. It's better to compare HPInstantInk versions and make manual changes.
Converting extensions can be complex. If you're not comfortable with code, consider the alternatives before diving in.

Newbie

Posts

Joined
Sat Jul 13, 2024 4:40 pm
Who is online

Users browsing this forum: No registered users and 9 guests