Post by malaiselvan » Wed Oct 28, 2020 1:54 am

I am a developer extending one of the 3rd party extension. I do not want to overwrite the core or the 3rd party. The 3rd party file is exist in the path "storage/modification/catalog/controller/checkout/checkout.php" and I am trying to override this file as below in my ocmod install xml file

Code: Select all

<file path="storage/modification/catalog/controller/checkout/checkout.php">
		<operation>
            <search><![CDATA[ /******* validate seller and check for maximum product limit ********/ ]]></search>
            <add position="before"><![CDATA[
				echo 'here'; die;
            ]]></add>
		</operation>
	</file>
After making this change, I dont see the change. I am not sure whether this is valid or not. Can someone please help. Thanks.

Newbie

Posts

Joined
Wed Oct 28, 2020 1:44 am

Post by thekrotek » Wed Oct 28, 2020 3:42 am

Name your modification file alphabetically so that it succeeds the desired modification. I mean name and code.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by IP_CAM » Wed Oct 28, 2020 4:04 am

Well, if your Idea is, to take that DB-stored File Code, and rework it again,
to then be used/displayed on screen instead, but this does sure NOT work
as planned, by use of the default OC Way of doing things. :laugh:

OcMod-Modification-Content is 'placed' into the Database, and, after a 'timed'
or 'manual' OcMod Cache-Reset, re-installed/refreshed in one 'Step', to then
work. This, by 'reworking/recoding' some Parts/Section(s) of the Content of the
'default' Code File Source, and then storing 'the Result' in the Database, where
that 'File'-content will be 'called' from, if used somewhere.
( Contrary to calling it from a cached xxxx.xml File, like in 'default' VqMod )
But an OcMod should not overwrite another OcMod, that would really make no sense.
---
It would be mucho simpler, to modify the 'existing' OcMod - XML-File, to contain
the Code, you want to add/change/whatever ... ;)

Good Luck! ;)
Ernie

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by thekrotek » Wed Oct 28, 2020 4:27 am

IP_CAM wrote:
Wed Oct 28, 2020 4:04 am
OcMod-Modification-Content is 'placed' into the Database
Database contains only original XML code and only if modification installed via Extension Installer. When put into "system" folder it goes directly into storage/modification folder, which is quite different.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by malaiselvan » Wed Oct 28, 2020 3:08 pm

Thanks for your reply. I am actually overriding the 3rd party extension 'Purpletree Multivendor' where they have placed their overrides under `storage/modification/` folder. So what I understand from your replies is that I cannot override those already modified files using my ocmod extension. The only way is to overwrite their modified files with my changes. Is my understanding correct?

Newbie

Posts

Joined
Wed Oct 28, 2020 1:44 am

Post by sw!tch » Wed Oct 28, 2020 3:12 pm

You might be able to use an event to achieve what you want. Depends on what you are trying to do?

https://github.com/opencart/opencart/wiki/Events-System

Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by malaiselvan » Wed Oct 28, 2020 5:44 pm

Thanks for your reply. Events looks interesting. Le me explain what I am trying to do.

I got a custom table where I maintain the seller id and the minimum order amount. When a customer clicks the checkout page, I need to do a call to a method, get all the products in the cart and the corresponding amount, check whether the cart amount (particular to a seller) is not less than the minimum order amount. In case if the total cart amount of such products (belong to the same seller) is minimum to the configured amount, then an error message needs to be raised and not to proceed further.

The checkout.php is now available under 'storage/modification/catalog/controller/checkout/checkout.php'

Can events address my requirement?

Newbie

Posts

Joined
Wed Oct 28, 2020 1:44 am

Post by DigitCart » Wed Oct 28, 2020 6:13 pm

Hi
Yes, Try these events:

Code: Select all

$this->load->model('setting/event');
$this->model_setting_event->addEvent('your_module', 'catalog/controller/checkout/checkout/before', 'extension/module/your_module/your_method');
$this->model_setting_event->addEvent('your_module', 'catalog/controller/checkout/confirm/before', 'extension/module/your_module/your_method');
If you are not using the default checkout, The events may be different.

My Extensions


User avatar
Active Member

Posts

Joined
Thu Jun 22, 2017 5:32 pm


Post by malaiselvan » Wed Oct 28, 2020 6:51 pm

Thanks for your reply. One last question before I start my coding.

If I create an event as 'before', will the event runs asynchronously or synchronously? In other words, will my code complete first then the core code continue? or will both run in parallel?

Newbie

Posts

Joined
Wed Oct 28, 2020 1:44 am

Post by straightlight » Wed Oct 28, 2020 7:33 pm

malaiselvan wrote:
Wed Oct 28, 2020 6:51 pm
Thanks for your reply. One last question before I start my coding.

If I create an event as 'before', will the event runs asynchronously or synchronously? In other words, will my code complete first then the core code continue? or will both run in parallel?
Unfortunately, it will run both at this time. I have sent my reviews about that on Github earlier this week as I do hope it will run parallel. However, if you are looking for both functionalities to run at the same time, then yes, it is already available.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: nonnedelectari and 232 guests