You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (($cartUpdatedNotice = $this->request->getParam('cartUpdatedNotice')) !== null) {
if (($cartUpdatedNotice = $this->request->getParam('cartUpdatedNotice')) !== null) {
$cartUpdatedMessage = Html::encode($cartUpdatedNotice);
Craft::$app->getDeprecator()->log('cartUpdatedNotice', 'The `cartUpdatedNotice` param has been deprecated for `carts/*` requests. Use a hashed `successMessage` param instead.');
} else {
$cartUpdatedMessage = Craft::t('app', 'Cart updated.');
}
if ($request->getAcceptsJson()) {
return$this->asJson([
'success' => !$this->_cart->hasErrors(),
$this->_cartVariable => $this->cartArray($this->_cart),
'message' => $cartUpdatedMessage,
]);
}
$this->setSuccessFlash($cartUpdatedMessage);
As the line $cartUpdatedMessage = Craft::t('app', 'Cart updated.'); sets the variable to "Cart updated"
It then directly references the variable 'message' => $cartUpdatedMessage, which then passes "Cart updated" back through the response regardless of the value.
When you look inside $this->setSuccessFlash($cartUpdatedMessage);
You can see it does the $message = $this->request->getValidatedBodyParam('successMessage') ?? $default;
Which would convert the body param into the value you supplied.
But as this code is never executed you get the hardcoded response for all JSON requests.
Thanks :)
UPDATE: I've found the failMessage doesn't get validated or converted by either the JSON or text/html responses e.g. the code does rather than setting the flash message.
When you send a hashed
successMessage
orfailMessage
to update the cart, the value does not get used for JSON responses.The code located:
commerce/src/controllers/CartController.php
Line 366 in 3d31e4c
As the line
$cartUpdatedMessage = Craft::t('app', 'Cart updated.');
sets the variable to "Cart updated"It then directly references the variable
'message' => $cartUpdatedMessage,
which then passes "Cart updated" back through the response regardless of the value.When you look inside
$this->setSuccessFlash($cartUpdatedMessage);
You can see it does the
$message = $this->request->getValidatedBodyParam('successMessage') ?? $default;
Which would convert the body param into the value you supplied.
But as this code is never executed you get the hardcoded response for all JSON requests.
Thanks :)
UPDATE: I've found the
failMessage
doesn't get validated or converted by either the JSON or text/html responses e.g. the code does rather than setting the flash message.The text was updated successfully, but these errors were encountered: