Post by BinkFour » Wed Apr 25, 2018 1:52 am

Opencart version: 3.0.2.0

I have created the following file: /domain/admin/controller/event/shippingrate.php

I have not been able to verify the following code.

Code: Select all

<?php
  class ControllerEventDisableFlatRate extends Controller {
    // catalog/model/extension/shipping/flat/before
    public function disableflatrate(&$route, &$data, &$output){
      if ((float)$this->cart->getTotal() >= $this->config->get('free_total')) {
      	$method_data = array();
      }
    }
  }
Event Information
Trigger

Code: Select all

catalog/model/extension/shipping/flat/before
Action

Code: Select all

event/shippingrate/disableflatrate
I have also added the following for verifying the output.

Code: Select all

echo "lalala".$this->config->get('free_total');
But no result or output.

The error.log has no references on events and I have not seen any other logs related to events.

How can I debug of anything is being triggered succesfully or not?

New member

Posts

Joined
Mon Jun 10, 2013 1:47 am


Post by acx » Thu Apr 26, 2018 7:52 am

Often times when Open carts' error.log is empty, the errors get logged to the server logs.

Check your control panel's error log and you'll likely find messages of interest.

Extensions I've made (free):

Breadcrumbs for 2.3.0.2 & 3.0.2.0 Breadcrumb links for subcategories & parent category on product pages
Product Requests Allow customers to request notifications for sold out products
Abandoned Carts Send inquiries to abandoned carts to complete checkout or provide feedback
Ghost Orders Cleanup residue left behind by one page checkout addons


acx
New member

Posts

Joined
Wed Mar 21, 2018 8:39 am


Post by BinkFour » Tue May 01, 2018 10:32 pm

You have put me on the right track or at least towards the next step.

Plesk logs revealed what get and posts were called but not a lot of the events that are called when calling index.php?route=checkout/checkout.
Therefore, I added

Code: Select all

echo $event."<br>";
To

Code: Select all

public function trigger($event, array $args = array()) {
in system/engine/event.php

This gave me an overview of events that are called.

I updated the trigger in the database to "catalog/model/extension/total/shipping/getTotal/after"

Now the event is actually called but when loading the page I get

Fatal error: Class 'Controllereventshippingrate' not found in D:\appdata\IIS\vhosts\domain\subdomain\vqmod\vqcache\vq2-storage_modification_system_engine_action.php on line 71

Any suggestion what to do with this error for an event file?

New member

Posts

Joined
Mon Jun 10, 2013 1:47 am


Post by acx » Wed May 02, 2018 12:08 am

Fatal error: Class 'Controllereventshippingrate' not found in D:\appdata\IIS\vhosts\domain\subdomain\vqmod\vqcache\vq2-storage_modification_system_engine_action.php on line 71
This is from vQmod, there's a missing class it expects to see, but doesn't: Controllereventshippingrate

- Clear the vQmod cache
- disable/uninstall any shipping rate addons

Earlier in your thread, you posted a bit of code with this class name: ControllerEventDisableFlatRate - is it possibly supposed to be named: ControllerEventShippingRate?

Extensions I've made (free):

Breadcrumbs for 2.3.0.2 & 3.0.2.0 Breadcrumb links for subcategories & parent category on product pages
Product Requests Allow customers to request notifications for sold out products
Abandoned Carts Send inquiries to abandoned carts to complete checkout or provide feedback
Ghost Orders Cleanup residue left behind by one page checkout addons


acx
New member

Posts

Joined
Wed Mar 21, 2018 8:39 am


Post by BinkFour » Wed May 02, 2018 10:01 pm

The renaming was indeed the cause of the problem. Although I cleared the VQcache and refreshed the modifications in OC it still expected the old class name somehow.

Anyway there is progress.

Is it possible to set a trigger on an extension index function?

Code: Select all

/ catalog/model/checkout/shipping/index/after
As soon as I have this figured out I will write my conclusions in a reply to close this thread.

New member

Posts

Joined
Mon Jun 10, 2013 1:47 am


Post by acx » Mon May 07, 2018 8:16 am

BinkFour wrote:
Wed May 02, 2018 10:01 pm
The renaming was indeed the cause of the problem. Although I cleared the VQcache and refreshed the modifications in OC it still expected the old class name somehow.
If this is an extension, you also need to clear the modification cache and/or update the code that is saved to the modification database table, that was calling the incorrect class name.
Is it possible to set a trigger on an extension index function?

Code: Select all

/ catalog/model/checkout/shipping/index/after
Not sure I fully understand this question, but if you want to trigger something specific, inside the class you fixed earlier, simply add a new function:

Code: Select all

public function after() {
    // do your 'after' stuff here
}

Extensions I've made (free):

Breadcrumbs for 2.3.0.2 & 3.0.2.0 Breadcrumb links for subcategories & parent category on product pages
Product Requests Allow customers to request notifications for sold out products
Abandoned Carts Send inquiries to abandoned carts to complete checkout or provide feedback
Ghost Orders Cleanup residue left behind by one page checkout addons


acx
New member

Posts

Joined
Wed Mar 21, 2018 8:39 am


Post by BinkFour » Fri Jul 06, 2018 7:41 pm

The debugging in the end resolved the problem. You can find and use the result from the following repository: https://github.com/LybaNL/Opencart_Even ... pping_Rate

New member

Posts

Joined
Mon Jun 10, 2013 1:47 am

Who is online

Users browsing this forum: Semrush [Bot] and 227 guests