- ๐ฉ๐ชGermany rgpublic Dรผsseldorf ๐ฉ๐ช ๐ช๐บ
Coming from https://www.drupal.org/project/commerce_cart_redirection/issues/3218501 โจ Suppress the " added to your cart" message on redirect? Closed: won't fix I have 2 questions:
* Is it really needed to have an option to set this per order-type? What is the use-case if I may ask? I have nothing against it, though. Just wondering...
* Could anyone of the core maintainers comment if this is feasible? Otherwise we'd have to find an out-of-core solution. I definitely think solving this in core makes more sense. At least as long as it's as difficult to switch the message off as it currently is.
BTW: Should we perhaps set this on "Needs review" to move this forward?
- ๐ฉ๐ชGermany rgpublic Dรผsseldorf ๐ฉ๐ช ๐ช๐บ
PS: Finding now #2810723 I wonder... Do we really need an additional option for this? If #2810723 ever gets implemented (switching off the cart completely per order-item), I'd assume the corresponding message disappears as well without any further configuration...?
- Status changed to Needs review
over 1 year ago 10:31am 8 April 2023 - ๐จ๐ญSwitzerland znerol
- A global setting whether the message is displayed or not wouldn't be sufficient in our case. This is because we sell books and subscriptions. In the former case the status message is desirable, in the latter case it is not (direct checkout).
- This issue will make โจ Allow order types to have no carts Needs work much simpler and cleaner to implement. I am currently using the patch from the other issue. If I was a maintainer, I wouldn't want to merge that in its current state though.
- ๐จ๐ญSwitzerland znerol
Added tests and a post update hook which is turning the setting on for all existing order types.
- @znerol opened merge request.
- Status changed to Needs work
over 1 year ago 9:00am 11 April 2023 - ๐ฎ๐ฑIsrael jsacksick
@znerol: Several issues with your patch, the main issue being that the setting must be added form the cart module.
See
commerce_cart_form_commerce_order_type_form_alter
commerce_cart_order_type_form_submit
.The setting must then be accessed like the following:
$display_add_to_cart_message = $order_type->getThirdPartySetting('commerce_cart', '<name of the setting>');
But also, I'm just unsure this is a good idea to just expose settings for everything... Disabling this programatically isn't really complicated but I know writing code isn't an option for everyone.
- ๐จ๐ญSwitzerland znerol
But also, I'm just unsure this is a good idea to just expose settings for everything... Disabling this programatically isn't really complicated but I know writing code isn't an option for everyone.
True. Ultimately my goal is to unblock issues like โจ Allow order types to have no carts Needs work and โจ Make it possible to not display the add to cart message when using ajax Needs work . If another approach with the potential to advance those issues is more viable, then I'm willing to implement that. Suggestions welcome.
- ๐ฉ๐ชGermany rgpublic Dรผsseldorf ๐ฉ๐ช ๐ช๐บ
But also, I'm just unsure this is a good idea to just expose settings for everything... Disabling this programatically isn't really complicated but I know writing code isn't an option for everyone.
Well, IMHO, Drupal from A to Z is only about making everything configurable. If you look at Views, many configuration pages in Commerce etc. etc. It's a flood of checkboxes, dropdowns etc. The problem I guess is that Drupal is missing sth. viable between writing a whole new module in PHP and just setting obscure checkboxes. Sth. like "about:config" in Firefox browser, for example. But, for the time being, I still think it would be nice if this message could easily be changed, translated etc. It would perhaps be sufficient if there was a Twig template suggestion to override this message. This would also make it possible to make the message dynamic (perhaps depending on the item just added etc.). And if this template is empty (to be defined what that means - perhaps a test with trim() equals empty string) the message is suppressed altogether. If there are individual template suggestions per order type, this issue here could be solved elegantly without any new UI but also without the need for writing modules. Just an idea.
- @znerol opened merge request.
- Status changed to Needs review
over 1 year ago 4:21pm 11 April 2023 - Status changed to Needs work
over 1 year ago 3:14pm 7 May 2023 - ๐บ๐ฆUkraine vlad.dancer Kyiv
Thank you @znerol. One thing to note we need to save cart_message value in submit function:
function commerce_cart_order_type_form_submit($form, FormStateInterface $form_state) { //... $order_type->setThirdPartySetting('commerce_cart', 'cart_message', $settings['cart_message']); }
- last update
over 1 year ago 783 pass - Status changed to Needs review
over 1 year ago 3:58pm 7 May 2023 - ๐จ๐ญSwitzerland znerol
Right, thanks for spotting that @vlad.dancer.
- Status changed to RTBC
over 1 year ago 2:47pm 8 May 2023 - ๐ฎ๐ฑIsrael jsacksick
Patch looks good, could we maybe just move the tests to the existing AddToCartFormTest?
We might just need the following method since we are already testing there that the ATC message is displayed:public function testNoAddToCartMessageWhenDisabled() { // Disable the add-to-cart message. $orderType = OrderType::load('default'); $orderType->setThirdPartySetting('commerce_cart', 'cart_message', FALSE); $orderType->save(); // Anonymous active cart. $this->drupalGet('product/' . $this->variation->getProductId()); $this->submitForm([], 'Add to cart'); $this->assertSession()->statusCodeEquals(200); $product = $this->variation->getProduct(); $this->assertSession()->pageTextNotContains('added to your cart.'); }
I'm also just unsure about the setting name? "cart_message" sounds like a setting that holds the actual message itself, and not whether or not it is enabled.
Maybe we should go with "enable_cart_message"?
- last update
over 1 year ago CI aborted - ๐ฎ๐ฑIsrael jsacksick
Moved the tests to the AddToCartFormTest and renamed the setting to "enable_cart_message".
- last update
over 1 year ago 782 pass - ๐ฎ๐ฑIsrael jsacksick
Same patch with an updated comment for the
testAddToCartMessageBehavior()
method. -
jsacksick โ
committed 2ff4881a on 8.x-2.x authored by
znerol โ
Issue #3317738 by znerol, jsacksick: Add an order type setting to allow...
-
jsacksick โ
committed 2ff4881a on 8.x-2.x authored by
znerol โ
- ๐ฎ๐ฑIsrael jsacksick
Went ahead and committed the updated version. @znerol: thanks for your contribution!
- Status changed to Fixed
over 1 year ago 1:51pm 23 May 2023 -
jsacksick โ
committed b38bfc5f on 3.0.x authored by
znerol โ
Issue #3317738 by znerol, jsacksick: Add an order type setting to allow...
-
jsacksick โ
committed b38bfc5f on 3.0.x authored by
znerol โ
Automatically closed - issue fixed for 2 weeks with no activity.