Open Daaaaad opened 6 years ago
Same problem here ... Did you remember the solution you implemented ?
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,
));
}`
Hi, have you found a solution because by moving the class below, the error does not change...
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 ?
Arf,
Yes, that's nice, here's my compressed file. I'm using PrestaShop 1.7.2.0 dpdbenelux.zip
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)
like that :
When I do this, I have this error:
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');
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?