Post by Jsf » Wed Jul 29, 2020 10:26 pm

Hi,

I want to change:

Code: Select all

$json['total'] = sprintf($this->language->get('text_wishlist'), $this->model_account_wishlist->getTotalWishlist());
To:

Code: Select all

$json['total'] = $this->model_account_wishlist->getTotalWishlist();
File: catalog/controller/account/wishlist.php
it is possible to do with OC Events (not with vqmod/ocmod) ?

User avatar
Jsf
New member

Posts

Joined
Sun Jan 26, 2014 4:08 am

Post by grgr » Thu Aug 13, 2020 11:04 am

Don't think you can, there will be no data passed/available to do anything with.
Do it with an OCMOD.

-
Image Image Image Image
VIEW ALL EXTENSIONS * EXTENSION SUPPORT * WEBSITE * CUSTOM REQUESTS


User avatar
Active Member

Posts

Joined
Mon Mar 28, 2011 4:08 pm
Location - UK

Post by JNeuhoff » Thu Aug 13, 2020 5:18 pm

You should be able to that with an event handler.

Code: Select all

	// event handler catalog/controller/account/wishlist/add/after
	public function eventControllerAccountWishlistAddAfter(&$route,&$data,&$output) {

		$this->load->controller('account/wishlist');

		// modify json['total']
		$json = json_decode($this->response->getOutput(),true);
		$json['total'] = $this->model_account_wishlist->getTotalWishlist();

		// update output
		$this->response->setOutput(json_encode($json));
	}
Last edited by JNeuhoff on Thu Aug 13, 2020 6:51 pm, edited 1 time in total.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by letxobnav » Thu Aug 13, 2020 5:25 pm

While I do not particularly like ocmod, (mis)using events for these kind of trivial changes by overriding generated output is even worse.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by JNeuhoff » Thu Aug 13, 2020 6:38 pm

letxobnav wrote:
Thu Aug 13, 2020 5:25 pm
While I do not particularly like ocmod, (mis)using events for these kind of trivial changes by overriding generated output is even worse.
That's your personal choice. But the controller/*/after events, and especially the view/*/after events, are exactly there for the purpose of modifying the output.

And it looks like there won't be an OCmod anymore starting with OpenCart 3.1.x releases.

Of course having more defined trigger points, e.g. when generating json output instead of the normal html, would be nice to have. Perhaps someone could suggest that to Daniel on github.
Last edited by JNeuhoff on Thu Aug 13, 2020 7:21 pm, edited 1 time in total.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by by mona » Thu Aug 13, 2020 6:54 pm

And it looks like there won't be an OCmod anymore starting with OpenCart 3.1.x releases.
and so are we to return to vQmod? so you will have to create for vqmod / ocmod / vqmod again and events .. WOW ..

https://www.opencart.com/index.php?rout ... n_id=22378
https://www.opencart.com/index.php?rout ... n_id=32203

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by JNeuhoff » Thu Aug 13, 2020 7:17 pm

Well, so far there are several modification systems available for OpenCart 3.0.x releases:
  • Theme editor in admin backend
  • Using your web theme with modified templates
  • Event Handlers
  • OCmod
  • VQmod (e.g. Integrated VQmod or Qphoria's vQmod)
  • Override Engine
It will be good to see this cleaned up a little bit, especially for the theme editor. Daniel is changing the way 3rd party extensions are managed in OpenCart 3.1.x, e.g. there will be a separate 'extension' folder, but no OCmod, from what I can see on github. XML is a text-based markup language for data and protocols, it's not meant to be a programming language.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by by mona » Thu Aug 13, 2020 8:02 pm

In principle - yes that is the point and it is a problem
but there was absolutely nothing wrong ( :banana: :ok: :dance: :yahoo: in fact) with Qphoria’s offering to the world, why invent the wheel again and the issue has arisen because that is what happened.

I would also like it to be cleaned up, it is by far the most obvious thing to do.

So surely the best solution would be to work with each other .. events has its uses .. the best thing about OCMOD above vQmod is that the later versions remove all the files (although sometimes that can be a little annoying if you want to streamline and not repeat files - ok - from developers perspective at least - pluses to me outweigh minus on that)

So remove the theme editor completely
Remove OCMOD completely
Go back (and integrate) Qphoria’s vQmod - (assuming he would agree to that of course)
Add a vQmod manager - maybe just for me add an option which files and folders to remove
Keep the events system

Job done and all the work is already there?

Daniel is more than entitled to do as he wishes, I actually think complaining about his wonderful offering, which gets more smilies than Qphoria’s from me, but no point to keep cutting off and obstructing the income supply. Already $20 is too high a starting point that gets too many people on here. To reduce it to $5 would have been better. Quality of extensions has nothing to do with the price, so that logic didn’t work.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by letxobnav » Thu Aug 13, 2020 8:41 pm

XML is a text-based markup language for data and protocols, it's not meant to be a programming language.
That is true but I beg to differ that the XML in OCMOD is not used as a "programming language" but as data.

While I do not use any of them, I would keep the theme editor for those users who only want to make small, simple and fast changes to the theme without needing the knowledge of xxMOD.

But I would suggest to enhance both xxMOD and the theme editor in that they flag possible conflicts both ways.
In the theme editor flag those files which exist in the modification directory with the message that they will override modifications if they proceed and those modifications will stop functioning.
When processing an xxMOD, check if the twig file is already present in the theme table and issue a warning that the modification being installed may not work properly or abort the processing, something like that.
I.e. a little more coordination between the different methods to avoid clashes.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by by mona » Thu Aug 13, 2020 9:44 pm

I.e. a little more coordination between the different methods to avoid clashes.
That is the exact problem .. there are clashes .. so it does need streamlining - YAY everyone agrees in principle ..

Whilst I understand the theme editor is a great idea for simple tasks and non-developers ..
Too many screens backwards and forwards to make the editor work - hard enough with the refresh cache on the modification page itself !
The clashes make it impossible to use
and OMG how many times has the 'go back to original file’ gets pressed 'accidentally' and EVERYTHING is lost ..

I would keep the theme editor for those users who only want to make small, simple and fast changes to the theme without needing the knowledge of xxMOD.
That could be done far more simply and robust and still run it through a single xxMOD

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by letxobnav » Fri Aug 14, 2020 10:09 am

True, not saying that theme editor works very well (I hate all js based online editing tools) but the concept is fine.
Problem with it is that when a person installs OC for the first time, that is what they will use as it requires very little skill, almost instant gratification (if they would automatically clear the theme cache on saving) and so they change many little things in many files.
After some time they become serious and start with installing extension, then the confusion starts as those extension do not seem to work as those theme table overrides are still in effect without any indication.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by straightlight » Fri Oct 30, 2020 2:28 am

JNeuhoff wrote:
Thu Aug 13, 2020 5:18 pm
You should be able to that with an event handler.

Code: Select all

	// event handler catalog/controller/account/wishlist/add/after
	public function eventControllerAccountWishlistAddAfter(&$route,&$data,&$output) {

		$this->load->controller('account/wishlist');

		// modify json['total']
		$json = json_decode($this->response->getOutput(),true);
		$json['total'] = $this->model_account_wishlist->getTotalWishlist();

		// update output
		$this->response->setOutput(json_encode($json));
	}
Thanks for this. This in an important step for all users wanting to make modifications to the cart total as well.
Last edited by straightlight on Fri Oct 30, 2020 7:11 pm, edited 1 time in total.

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

Post by JNeuhoff » Fri Oct 30, 2020 6:00 pm

The 'Content-Type: application/json' is already in the response header, there is no need to repeat it. All this event handler does is to modify the json output.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by straightlight » Fri Oct 30, 2020 7:11 pm

JNeuhoff wrote:
Fri Oct 30, 2020 6:00 pm
The 'Content-Type: application/json' is already in the response header, there is no need to repeat it. All this event handler does is to modify the json output.
Ok, I have modified my post above.

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: Semrush [Bot] and 260 guests