Prestashop 1.7.7. Error When Proceed to Checkout - prestashop

Like I explain at the title this issue it's related with the checkout of prestashop version 1.7.7.0.
When I add I product to the cart, and then I press the button to proceed to the checkout I have this issue:
[21-Jun-2021 22:39:57 Europe/Madrid] PHP Fatal error: Uncaught Error: Call to undefined method Cart::checkAllProductsAreStillAvailableInThisState() in /home/public_html/classes/checkout/CheckoutPaymentStep.php:48
Stack trace:
#0 /home/public_html/classes/checkout/CheckoutProcess.php(59): CheckoutPaymentStepCore->handleRequest(Array)
#1 /home/public_html/controllers/front/OrderController.php(278): CheckoutProcessCore->handleRequest(Array)
#2 /home/public_html/classes/controller/Controller.php(306): OrderControllerCore->initContent()
#3 /home/public_html/classes/Dispatcher.php(518): ControllerCore->run()
#4 /home/public_html/index.php(28): DispatcherCore->dispatch()
#5 {main}
thrown in /home/public_html/classes/checkout/CheckoutPaymentStep.php on line 48
I have made some test:
Disable all the modules and have only to the native ones of Prestashop.
Tried with a clean install and always i have the same problem.
No matters if it's the default theme or the bought one.
Delete the cache of prestashop...
Clearly i'm desesperate with this problem... Any help will be so apreciate.

Hello again for all the community,
I have solve the problem by commenting some lines of code.
Get this archive and edit it.
Classes > Checkout > CheckoutPaymentStep.php
public function handleRequest(array $requestParams = [])
{
$cart = $this->getCheckoutSession()->getCart();
$allProductsInStock = $cart->isAllProductsInStock();
//$allProductsExist = $cart->checkAllProductsAreStillAvailableInThisState(); /*-- Comment this --*/
//$allProductsHaveMinimalQuantity = $cart->checkAllProductsHaveMinimalQuantities(); /*-- Comment this --*/
//if ($allProductsInStock !== true || $allProductsExist !== true || $allProductsHaveMinimalQuantity !== true) /*-- Change this one --*/
if ($allProductsInStock !== true) {
$cartShowUrl = $this->context->link->getPageLink(
'cart',
null,
$this->context->language->id,
[
'action' => 'show',
],
false,
null,
false
);
Tools::redirect($cartShowUrl);
}
if (isset($requestParams['select_payment_option'])) {
$this->selected_payment_option = $requestParams['select_payment_option'];
}
$this->setTitle(
$this->getTranslator()->trans(
'Payment',
[],
'Shop.Theme.Checkout'
)
);
}
For now all goes well and we can process to the checkout. Hope if someone have the same problem, could help you.
Nancy.

Related

Yii2 redirect to previous page after update review

I have a page comp/computer?id=15
it has reviews that can be edited through link
http://comp/computer/update?id=3 = with FORM and submit button
how to go back after sumbit
public function actionUpdate($id)
{
$model = new ReviewForm();
$comment = Review::findOne($id);
if ($model->load($this->request->post())) {
$comment->text = $model->text;
if ($comment->save(false)) {
return $this->redirect(["?id=15"], ); ????????????
}
Yii::$app->session->setFlash(
'success',
'Success'
);
}
$model->setAttributes($comment->getAttributes(['name', 'email', 'text']));
return $this->render('update', compact('model'));
}
simply use referrer.
return $this->redirect(Yii::$app->request->referrer)
If it has no referrer or link open directly then you should either pass computer_id as param or you must have computer_id as foreign key in your review table.
Let say you have relationship with review and computer table. then you can use like this.
$compId = $comment->computer_id; // or 15 or you can paas param here
return $this->redirect(["comp/computer", "id"=> $compId]);
if comp is your hostname then
return $this->redirect(["computer", "id"=> $compId]);
its should be controller/action
return $this->redirect(["controllerId/actionId", "id"=> $compId]);
Send via mobile, sorry for typos.

Catalog product page gives error 500 after upgrade from 1.7.3 to 1.7.6

I can't access the product catalog page or edit any products after upgrading from 1.7.3.1 to 1.7.6.1
It gives me two fatal php errors.
The first exception: Twig\Error\RuntimeError
in src/PrestaShopBundle/Resources/views/Admin/layout.html.twig (line 34)
layoutHeaderToolbarBtn is defined ? layoutHeaderToolbarBtn : [],
layoutDisplayType is defined ? layoutDisplayType : '',
showContentHeader is defined ? showContentHeader : true,
headerTabContent is defined ? headerTabContent : '',
enableSidebar is defined ? enableSidebar : false,
Line 34 help_link is defined ? help_link : ''
)
)) %}
{% import '#PrestaShop/Admin/macros.html.twig' as ps %}
The second exception: Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
in vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php (line 348)
if ($lev <= \strlen($id) / 3 || false !== strpos($knownId, $id)) {
$alternatives[] = $knownId;
}
}
throw new ServiceNotFoundException($id, null, null, $alternatives);
}[enter image description here][1]
}
/**
* Returns true if the given service has actually been initialized.
Cross posted here https://www.prestashop.com/forums/topic/1003821-catalog-product-page-gives-error-500-after-upgrade-from-173-to-176/
Error screenshot
Turns out, that the related products module was not updated. It's a module bought on the Marketplace. I checked the compatibility and it said it was compatible with 1.7.6.1, so for that reason, combined with my backoffice telling me i had 0 available updates and that the module was up to date, i assumed it was all good.
But apparently, modules bought on the marketplace, don't have their updates show up in prestashop. 
I fixed the issue, by uninstalling the related products module and downloading the newest one 1.6.4 instead of 1.6.3 from the prestashop marketplace.

Angular 6, catching ' error/not valid parameter ' in activated route

I am facing a problem with route parameter error catching. Here is the situation explained below.
The route params are as follows for displaying data in components of navbar:
http://localhost:4200/{ company_type }/{ company_name }/{ org-id }/{ component_name }
The website is opening even when I change the company_name to any string and company_id to null || 14cd156. I will get articles when I change company name in route. But, when I change id I get an error
core.js:1624 ERROR Error: Uncaught (in promise): HttpErrorResponse: {"headers":{"normalizedNames":{},"lazyUpdate":null},"status":404,"statusText":"Not Found","url" ...
The API doesn't check for company name. It only checks the company id company coming from route params. What I want to do is: to navigate to not-found page in case the company_name and company_id are invalid. Let's say,
company_type = consulting
company_name = ABC
id = 1
page=Article
In page Article when I change http://localhost:4200/consulting/ABC/5/articles to http://localhost:4200/consulting/3edsads/5/artciles the website shows data of Articles page. But, the data is route parameter is wrong.
articles.component.ts
getOrgArticles(page: number = 1) {
let queryParams = this.getQueryParams(page);
this.queryArticles =
this.service.getOrgArticles(queryParams).
subscribe((data: any) => {
this.page = page;
this.pageSize = queryParams['per-page'] || this.pageSize;
this.articles = this.articles.concat(data['articles']);
this.pageCount = data._meta.pageCount;
this.isLastPage() ? this.hideNextButton() : this.showNextButton();
this.totalCount = data._meta.totalCount;
},
error => {
});
}
service.ts
getOrgArticles(queryParams) {
const qpString = this.queryString(queryParams);
return this.http.get(`${this.api}/articles?${qpString}`);
}
I really wish to find some solution from you. Thank you

PayPal Api Patch on Itemlist doesn't work

I want to add an item to my transaction.
$json = '
[
{
"name": "Voucher",
"description":"Voucher",
"price":"50.00",
"currency":"EUR",
"quantity":"1"
}
]';
$patchAddItem = new \PayPal\Api\Patch();
$patchAddItem->setOp('add')
->setPath('/transactions/0/item_list/items')
->setValue(json_decode($json));
$patchReplace = new \PayPal\Api\Patch();
$patchReplace->setOp('replace')
->setPath('/transactions/0/amount')
->setValue(json_decode('{
"total": "159.00",
"currency": "EUR",
}'));
$patchRequest = new \PayPal\Api\PatchRequest();
$patchRequest->setPatches(array($patchAddItem, $patchReplace));
try {
$this->payment->update($patchRequest, $this->apiContext);
} catch (PayPal\Exception\PayPalConnectionExceptio $ex) {
echo '<pre>';print_r(json_decode($ex->getData()));exit;
}
But I get following Error
Eception: Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment/PAY... in PayPal-PHP-SDK/paypal/rest-api-sdk-php/lib/PayPal/Core/PayPalHttpConnection.php on line 154
PayPal-PHP-SDK/paypal/rest-api-sdk-php/lib/PayPal/Transport/PayPalRestCall.php on line 73: PayPal\Core\PayPalHttpConnection->execute("[{"op":"add","path":"/transactions/0/item_list/ite"... )
PayPal-PHP-SDK/paypal/rest-api-sdk-php/lib/PayPal/Common/PayPalResourceModel.php on line 102: PayPal\Transport\PayPalRestCall->execute(array[1],"/v1/payments/payment/PAY-1S151200BX2478240LEAG3CI","PATCH","[{"op":"add","path":"/transactions/0/item_list/ite"... ,null)
PayPal-PHP-SDK/paypal/rest-api-sdk-php/lib/PayPal/Api/Payment.php on line 615: PayPal\Common\PayPalResourceModel::executeCall("/v1/payments/payment/PAY-1S151200BX2478240LEAG3CI","PATCH","[{"op":"add","path":"/transactions/0/item_list/ite"... ,null,object,null)
At this moment I didn't execute the payment object. Do I have to edit the total attribut from amount too? Well, I tried this too, with same issue...
Even if you are sending only one item to PayPal you still have to set them as an item list with setItemList().
That array should be visible if you json_decode in your payment array:
[item_list] => Array
(
[items] => Array
(
[0] => Array
(
[name] => Ground Coffee 40 oz
[sku] => 123123
[price] => 52.80
[currency] => USD
[quantity] => 1
)
)
I had not run a patch for an item yet. I attempted to send an 'add' similar to your code and tried changing the path to '/transactions/0/item_list/items/1' using the next number in the items array. But could not get an add to work.
The only way I could modify the item_list was to do a complete 'replace' of the item_list, so in a running shopping cart would have to include all the items being purchased, not just the new item.
To do this I prefer to use the functions from the PayPal sdk vs building the json arrays. Their examples of how to create and execute a payment are fairly good and use the SDK functions. http://paypal.github.io/PayPal-PHP-SDK/sample/
However the example on updating a payments builds the json arrays outright.
Below is a testing function to modify the item_list using the Paypay PHP SDK Class Functions. I hard coded the Subtotal and Total to match the values coming form the shopping cart plus the increase from the new item. The item_list is also hard coded using PP's example data. Otherwise item's arrays would be built off of a user's shopping cart items. The type is set to 'replace'.
So, yes. Subtotals and Totals need to be updated to match as well, else the PP call will fail.
function updatePayPalPayment ($type, $createdPayment, $total, $subtotal, $shipping, $currency) {
$subtotal = '54.80';
$total = '71.73';
$details = new Details();
$details->setShipping($shipping)
->setSubtotal($subtotal);
$amount = new Amount();
$amount->setCurrency($currency)
->setTotal($total)
->setDetails($details);
$item1 = new Item();
$item1->setName('Ground Coffee 40 oz')
->setCurrency('USD')
->setQuantity(1)
->setSku("123123") // Similar to `item_number` in Classic API
->setPrice(52.80);
$item2 = new Item();
$item2->setName('Granola bars')
->setCurrency('USD')
->setQuantity(1)
->setSku("321321") // Similar to `item_number` in Classic API
->setPrice(2.0);
$itemList = new ItemList();
$itemList->setItems(array($item1, $item2));
$patchItem = new Patch();
$patchItem->setOp($type)
->setPath('/transactions/0/item_list')
->setValue($itemList);
$patchAmount = new Patch();
$patchAmount->setOp($type)
->setPath('/transactions/0/amount')
->setValue($amount);
$patchRequest = new PatchRequest();
$patchRequest->setPatches(array($patchAmount, $patchItem));
$update = $createdPayment->update($patchRequest, getApiContext());
return $update;
}
I also have found it very helpful to set the apiContext for logging to DEBUG and output to a file in development for much better error messages.
'log.LogEnabled' => true,
'log.FileName' => '_PayPal.log',
'log.LogLevel' => 'DEBUG',
Hope that helps.

aurelia - computedFrom

I have the following:
.ensure('baseContent.ValidFromDate', (config) => { config.computedFrom(['baseContent.ValidFromDate', 'baseContent.ValidFromTime', 'baseContent.ValidToDate', 'baseContent.ValidToTime']) })
.if(() => {
return this.baseContent.ValidFromDate !== null && this.baseContent.ValidFromTime !== null && this.baseContent.ValidToDate !== null && this.baseContent.ValidToTime !== null })
.passes( () => { return this.datetimeformat.format(this.baseContent.ValidFromDate, this.baseContent.ValidFromTime) < this.datetimeformat.format(this.baseContent.ValidToDate, this.baseContent.ValidToTime) })
.withMessage('< Valid To')
.endIf()
I believed that config.computedFrom(['baseContent.ValidFromDate', 'baseContent.ValidFromTime', 'baseContent.ValidToDate', 'baseContent.ValidToTime']) - meant that if one of these values changed it would re-run the validation? However it only does this on 'baseContent.ValidFromDate', what am I missing / not understanding?
UPDATE
Seems the issue is to do with computedFrom doesn't support paths, don't really know another way round this barring adding this validation to the four items
This feature was added last week (aurelia-binding 1.0.0-beta.1.3.0). See https://github.com/aurelia/binding/issues/149
Syntax when used as a decorator is:
#computedFrom('obj.firstName', 'obj.lastName')