We intend to use Basic Cart module for a webshop with several suppliers. The customer can select which supplier he wants to use for delivery of the products. When an order is generated, we need to send an email to the selected supplier. This can be done via an ECA rule (https://www.drupal.org/project/eca) with the corresponding condition. But when the token [basic_cart_order:products] is used in an email created by the ECA rule to insert the cart content in the email body, it provides no value. It works fine however, when the token is used in an email notification created by the Basic Cart module itself. But for this notification the recipient cannot be defined conditionally.

I guess so far the [basic_cart_order:products] token is only available for Basic Cart module itself. Can it be made available system-wide so that other modules like ECA can use it as well?

Issue fork basic_cart-3564237

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

publishing future created an issue. See original summary.

norman.lol’s picture

I think the underlying reason for the token not being available for ECA is that at that moment the local cart got emptied already.

I think the probably most robust solution would be to introduce a token to get the products per order node ID, something like:

[basic_cart_order:123:products]

Can with ECA the token be build dynamically? Like [basic_cart_order:{{ node.id }}:products]?

Then we could introduce that token.

norman.lol’s picture

Status: Active » Postponed (maintainer needs more info)

Ah, since Basic Cart orders simply are nodes and the the reference field is named basic_cart_content you should in ECA or anywhere also also be able to just do this:

[node:basic_cart_content]

Can you try, please?

publishing future’s picture

Thank you for your fast reply! Yes, I already tried [node:basic_cart_content], but this only returns the product titles, but not the number of items per product nor the prices.

Building the the token with ECA dynamically like [basic_cart_order:{{ node.id }}:products] is doable. I would be happy to test this.

norman.lol’s picture

Version: 8.x-8.11 » 8.x-8.x-dev
Status: Postponed (maintainer needs more info) » Needs review
Issue tags: -token

Looked into Tokens

Tokens don't accept arguments, so we can't have [node:123:products]

Tokens simply come with the current node, so we can have [node:basic_cart_order_products]

I added the [node:basic_cart_order_products] token, please test it and please find somebody to help working on this issue if the code needs more changes

norman.lol’s picture

Title: Make [basic_cart_order:products] available as system-wide token » Make [node:basic_cart_order_products] available as system-wide token
norman.lol’s picture

Any chance you get that tested?

vistree’s picture

Hi @norman.lol, thank your for your work. The patch seems to work. We get the title and count of each product within ECA.
One question: as we need to add additional product infos (custom ISBN field) to the token - can we alter the new tokens?

norman.lol’s picture

Version: 8.x-8.x-dev » 8.x-8.11
Status: Needs review » Active

We could maybe provide another token that displays the product in a certain view mode if exists. And you can make that view mode display any info you need. You would need to take care of the markup yourself then, like stripping unwanted wrappers or lines breaks.

norman.lol’s picture

Version: 8.x-8.11 » 8.x-8.x-dev
Status: Active » Needs review
vistree’s picture

@norman.lol - Everything works fine for me with the current MR. I were able to use the new code to create a custom extended token in a simple hook function.
So for me everythings is perfectly good. Can this be committed?

norman.lol’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +GlobalContributionWeekend2026

I take that as RTBC. Let's get it out then.

  • norman.lol committed b1c5db46 on 8.x-8.x
    #3564237 Provide [node:basic_cart_order_products] token
    
norman.lol’s picture

Status: Reviewed & tested by the community » Fixed

Released. Please update the module and keep testing. Thank you

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

publishing future’s picture

I have been able to test the token successfully as well. Thank you for providing this improvement!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.