Questions tagged as ['commerce']
In D7, there was a module named 'Commerce price by components' which allowed us to display a price inclusive or exclusive of tax. I would like to show a detailed tax breakdown at checkout as most of my store's products are tax exempt, but some are not.
Is it possible in D8 to show the a price inclusive and exclusive of tax as two columns in the checkout summary / review table? Or is it possible to show ...

Is it possible - anyone know how - to run php code on a commerce 2 variations created field to check the data in that field maybe using Ajax to make the field typingsensitive in the checkout?? I read through https://www.drupal.org/project/commerce/issues/3103537 but but the code there. The field would be used to verify an imei or Vin number before the purchase can be made. ( I have code to count k ...

I am trying to add user custom field in order receipt pdf using below file commerce_purchase_order under template.
commerce-order-receipt--purchase-order-gateway.html.twig
I tried below code
{% for order_item in order_entity.getItems %}
{{ order_item|commerce_entity_render('field_custom_fielname') }}
{% endfor %}
Also Used but this will not work as this is not field in order
...
As administrator when I visualize the page for the order of a user (user/[user-id]/orders/[order-id]
) I can see the shipping and billing address.
But setting the same type of information for authenticated users that are not administrators, the addresses are not shown in the summary of the order, despite I have modified the display of the order for users (/admin/commerce/config/order-types/default/ ...
I am trying to get variation type field values from the order entity but I can't find any documentation on this. I am using an event subscriber to run the following code when an order is paid. The code works, but I can't see any reference to the fields in kint and I can't find any references to any kind of "getVariation" or equivalent function online.
/**
* This method is called when the commerce_or ...
I have created Drupal 9 website. On the website we accept donations using Commerce with Commerce Stripe as the payment processor. By default, the payment button says "Pay and complete purchase". As users are not purchasing anything, I want to change the text to something like "Donate Now". I have searched for answers online but all seem to point to the module String Overrides, which is D7 only and doesn ...
I have product type event, this event have registration fees if price value not zero.
Product page built with views and I embed related webform inside it.
am using module called commerce webform order: which add handler to webform to create order and redirect user after submit webform to checkout page.
Currently I use fixed selected variant as screenshot below
This field needs to be filed with product I ...

How to generate order pdf in drupal commerce and attach in hook_mail_alter using custom code. I trying another of method but seems not worked for me

How do I attach a pdf file to the commerce email?
I have invoice commerce.
Invoice commerce show view pdf option on every order and I want to send that pdf in email
I am stumped on how to get the pdf into a File object.
module_name_mail_alter(&$message) {
$my_attachment = array(
'filecontent' => $pdf,
'filemime' => $pdf->filemime,
'filename' => $pdf->filename,
'filepath' => ...

Can anyone point me to a right direction. I have created a custom Checkout flow and it has payment pane in it.
I'm trying to skip payment pane if the Cart state changed (default cart state is draft) I couldn't find any documentation for this in Drupal Commerce documentation or through Google.
I don't know what hook is available for this (if there is any) or where to start.
Thanks

I have been struggling with this for quite some time. I am trying to install a demo of the Commerce module as provided by Centarro, but every time the install finishes, I only get an empty site with the Beograd theme enabled but no product catalogue at all.
Here's what I do every time I try.
I install the Commerce module via
composer create-project
.composer create-project drupalcommerce/demo-project dem ...
I want to show a coupon code used on an order details page, but cannot seem to render it on a templates. Here are some things I have tried so far...
{% for coupon in order_entity.coupons %}
{{ coupon.target_id }}
{{ coupon.code }}
{{ drupal_entity('commerce_promotion_coupon', coupon.target_id) }}
{{ drupal_field('code', 'commerce_promotion_coupon', coupon.target_id) }}
{% endfor %}
The only th ...

It may be easiest to start with an example.
The entity_metadata_wrapper() function seems to do a lot of complex magic behind the scenes in order to return an object with all data related to the entity in question. But how do I know what properties and methods are available to me once the object is returned?
Let's say I have Commerce Order. (This is not necessarily a Commerce question, it's just good ...
Add to Cart button shows up only in Product/Views/blocks, But not anywhere else. It doesn't show anywhere else either logged in or not. There are variations, skus, price in most products, but no button. Appreciate advice, thanks Mike B.
I'm building a store with Drupal Commerce and creating my own off-site payment gateway. On the review page, after selecting payment method, the user can click the button to pay and finish the order. After that he's redirected to a page that tells him to wait to be redirected to the payment provider.
Is there a way to redirect the user to the payment provider without needing to go to this useless ...
Right now i have a payment method called "Transferência Bancária" and I need it to change to the workflow state "Awaiting Transferencia" automatically when that payment method is selected.
Is it possible to do programmatically?
I'm stuck at:
$order = $event->getEntity(); if(($order->getPaymentGateway()) == ('transferencia')) { $order->set('state', 'aguardando_transferencia'); }
on my /mo ...
In Drupal 9, I have defined the following order workflow for Drupal Commerce:
miss_pomela_fulfillment_processing:
id: miss_pomela_fulfillment_processing
group: commerce_order
label: 'Miss Pomela Fulfillment, with processing'
states:
draft:
label: Draft
pending:
label: Pending
processing:
label: En preparación
packed:
label: Ready to ship
fulfillm ...
I'm trying to migrate order data from an existing site using CSV files and I can't get the billing profile to relate.
In trying to troubleshoot this, I have it set just to insert a default value of a known profile and it's still not working for me. Currently, in the process section of my YML migration file I have these lines, but I still end up with <null>
in the database.
billing_profile/targ ...

There are a bunch of product images that are named same as SKU, so I'm just using field--commerce-product-variation--sku.html.twig to show them. All is fine.
I'd like to use the parent product image as fallback image for when the SKU image doesn't exist.
How do I access a parent product field from the product variation field template?

Let's say I have an Entity with a custom integer field added. Let's call the field Global Total (field_global_total)
On some event, I want to
get the existing value of that field and store it in a variable
get the value of another integer field (from another entity) and store that in a variable
add the two variables together
save that sum as the new value of "Global Total"
Ultimately I want ...
I followed Orders to write the following code.
$order = \Drupal\commerce_order\Entity\Order::create([
'type' => 'custom_order_type',
'state' => 'draft',
'mail' => 'user@example.com',
'uid' => 1,
'ip_address' => '127.0.0.1',
'order_number' => '6',
'billing_profile' => $profile,
'store_id' => $store->id(),
'order_items' => [$order_item],
'placed' => ...
Drupal 9, Drupal Commerce 2.26 I have an event subscriber, listening to CartEvents .. specifically CartEvents::CART_ORDER_ITEM_UPDATE
I have products of one type that reference products of another type.
The goal is when user updates order item for product of type 'class' in the cart, the order item for matching material_kit quantity is updated to match.
I have similar event subscribers, that allows me ...
In the products page, I want to limit product variations based on user roles. For example, I only want admin to be able to see some of the product variation. I tried to achieve this by adding an extra field in variation and then checking that field in twig template (commerce-product.html.twig). Unfortunately, this method only works with rendered entity and I couldn't use the "add to cart" functionality. ...
I am trying to figure out if it is possible to have product attributes that do not require individual SKUs and do not have to be entered as product variations. My use case is this: We are selling dinners with three different entrees and three different desserts. We do not need to charge different amounts for each combination, but we do need to know how many of each have been ordered. I can make this ...
I'm using the following jsonapi GET request to retrieve product variations for a product:
/jsonapi/commerce_product/default/0ea927c7-b62d-45c9-8bec-dc3d16215276/variations?include=field_images
However, the response does not include the file url for the media:
{
"type": "media--image",
"id": "6af50149-ae35-4a3b-802d-b21c5d863235",
"links": {
"self": {
"href": "http://myurl/en/jsonapi/media/image/6 ...
I'm using:
- Drupal 9.1.7
- Commerce 2.24
I'm trying to create my custom condition (based on https://docs.drupalcommerce.org/commerce2/developer-guide/core/conditions). However parent entity is always NULL. Seems like parent entity is only working when I specify commerce_order
as entity_type
only, but I need commerce_order_item
. ParentEntityAwareInterface
and ParentEntityAwareTrait
are in use. Debugging s ...

I am running Drupal 8 with Commerce 2.
I have a flat-rate shipping option set up for multiple regions and I now need to increase the shipping costs under certain circumstances, eg.:
- Order contains a specific product but not another specific product
- Order contains a product from any category except a specific one
- Order contains products from a certain category totaling over price x
The "rules" in the s ...
I'm running into composer errors while trying to update a Drupal Commerce site to Drupal 9.2.4.
I'm not sure how to interpret this output when I try composer prohibits drupal/core 9.2.4
results: https://pastebin.com/EWaDQejD
eg: drupal/core 9.2.4 requires twig/twig (^2.12.0) drupalcommerce/project-base - does not require twig/twig (but v1.44.4 is installed)
Not s ...
The "Upgrade Status" module reports that "Commerce Base" exists in site file structure, but is not installed and suggests removing it. I expect that the Commerce project references those files to work, but I don't know.
Should this project in my composer/json 'requires' list be removed using Composer? "drupalcommerce/commerce_base": "dev-8.x-1.x",
My original Drupal 8 install was with Composer u ...