DPDBeNeLux / DPD-Shipping-for-Prestashop-1.6

Let op: er zijn nieuwe DPD plugins (BETA versie) beschikbaar met belangrijke nieuwe functionaliteiten. De oude plugins zullen na Brexit niet meer goed functioneren, download daarom de nieuwe versie op Github/DPDconnect.
GNU General Public License v3.0
0 stars 2 forks source link

Fatal error: Class 'DpdCarrier' not found #3

Open Daaaaad opened 6 years ago

Daaaaad commented 6 years ago

Hello, I have a problem with the new module...

I installed it and configured it correctly but I get this error message in the order process : "Fatal error: Class 'DpdCarrier' not found in xxx/override/controllers/front/OrderController.php on line 374"

I checked the source and found that the code injected in OrderController (override) is called before the dpdbenelux module is loaded :

public function construct() { parent::construct(); $this->dpdCarrier = new DpdCarrier(); }

OrderController constructor is called before requiring DpdCarrier class file...

Can you help?

peterkenne commented 5 years ago

Same problem here ... Did you remember the solution you implemented ?

peterkenne commented 5 years ago

The solution applied here is to transfer the new DpdCarrier from the construct to the _assignWrappingAndTOS method. But I have the feeling the new was done in the construct for a certain reason ... The DPD module installed here has been installed after the install of another version (in which I see there exist another DpdCarrier class at another place, I had to delete the directory of the old module). Was it also the case for you ? public function __construct() `

{
    parent::__construct();
    //$this->dpdCarrier = new DpdCarrier();
}
public function _assignWrappingAndTOS()
{
    parent::_assignWrappingAndTOS();
    $this->dpdCarrier = new DpdCarrier();
    $deliveryOptionList = $this->context->cart->getDeliveryOptionList();
    $saturdayCarrierId = $this->dpdCarrier->getLatestCarrierByReferenceId(Configuration::get('dpdbenelux_saturday'));
    $classicSaturdayCarrierId = $this->dpdCarrier->getLatestCarrierByReferenceId(Configuration::get('dpdbenelux_classic_saturday'));
    foreach($deliveryOptionList as &$carriers){
        if(!$this->dpdCarrier->checkIfSaturdayAllowed()) {
            unset($carriers[$saturdayCarrierId . ',']);
            unset($carriers[$classicSaturdayCarrierId . ',']);
        }
    }
    $this->context->smarty->assign(array(
        'delivery_option_list' => $deliveryOptionList,
    ));
}`
Lionel-dev commented 5 years ago

Hi, have you found a solution because by moving the class below, the error does not change...

peterkenne commented 5 years ago

I confirm that this solved our problem. If you want, you can provide the zip of your module, and I will compare it with mine. Which version of PrestaShop do you have ?

Lionel-dev commented 5 years ago

Arf,

Yes, that's nice, here's my compressed file. I'm using PrestaShop 1.7.2.0 dpdbenelux.zip

peterkenne commented 5 years ago

OK, I see, the correction seems not to have been done, maybe my post was not clear enough ;-) You have to remove the line $this->dpdCarrier = new DpdCarrier(); from the _construct method of the class override/controllers/front/OrderController to the method _assignWrappingAndTOS In my preceding post, you can see the line commented, and the line added 5 lines after. I hope this will work, the other solution is that there is a problems specific to PRestaShop 1.7, as I am mainly working with the 1.6 (and correction has been done in a 1.6)

Lionel-dev commented 5 years ago

like that : image

When I do this, I have this error:

image

peterkenne commented 5 years ago

Sorry, can't help more, this is probably another problem than the one Daaad mentioned and that I encountered. Seem to be a problem of finding a class

Maybe check if all the constants (_PS_MODULEDIR , DIRECTORY_SEPARATOR) are ok, as I see a use for DpdDeliveryOptionsFinder at the start of your override of OrderController

require_once (_PS_MODULEDIR . 'dpdbenelux' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'DpdCarrier.php'); require_once (_PS_MODULEDIR . 'dpdbenelux' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'DpdDeliveryOptionsFinder.php'); require_once (_PS_MODULEDIR . 'dpdbenelux' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'DpdCheckoutDeliveryStep.php');