Questions tagged as ['commerce']

One of the modules that implements an eCommerce framework and ecosystem is the Drupal Commerce module.
Score: 0
griz avatar
How can I show tax per line item at checkout?
jp flag

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  ...

Score: 0
Run php code on text field in variation possible?
cn flag

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 ...

Score: 0
How to get user custom field in order email twig
ls flag

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

   ...
Score: 0
jmzea avatar
How can I give access to shipping information to authenticated users?
br flag

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/ ...

Score: 0
yuuuu avatar
Programmatically getting variation type fields in order
ao flag

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 ...
Score: 0
Order item - title missing product attributtes
ng flag

i'm placing a manual order, and when I search for a product, I have only the sku and the title, but with that I don't know the size for example or the color, as they are attributes, how can I do to have those information in the autocomplete, see image. order item autocomplete enter image description here

Score: 0
FrankDesign avatar
Drupal 9 Commerce change the Pay button text
cn flag

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 ...

Score: 1
Fadi Alkhatib avatar
Adding Current Product page Variant ID/SKU to webform submission Drupal 8
it flag

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

enter image description here

This field needs to be filed with product I ...

Score: 0
How to generate order pdf in drupal commerce and attach in hook_mail_alter
in flag

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

Score: 0
Attach PDF file to Drupal Commerce Order Notification generated with invoice commerce
ls flag

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' => ...
Score: 0
Hide pane based on cart state
tr flag

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

Score: 1
How do I install a working demo?
us flag

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.

  1. I install the Commerce module via composer create-project.

    composer create-project drupalcommerce/demo-project dem ...

Score: 1
Delford Chaffin avatar
How do I render a commerce promotion coupon code on the order details?
gg flag

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 ...

Score: 0
How do I know what properties and methods are available to an entity_metadata_wrapper object?
us flag

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 ...

Score: 0
Mike Burman avatar
Add to Cart button shows in Product/Views But not anywhere else
us flag

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.

Score: 1
Leeroy avatar
Redirect directly to the payment provider page
ca flag

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  ...

Score: -3
Tak avatar
Change workflow state with particular payment method
jp flag
Tak

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 ...

Score: 0
jmzea avatar
Syncing of order and shipping states
br flag

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 ...
Score: 2
Delford Chaffin avatar
Migrate order billing profile
gg flag

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 ...
Score: 0
Access product field from variation field
cn flag

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?

Score: 0
With Rules, how do I use variables with Calculate and Set a value actions?
us flag

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 ...

Score: 1
Aves2432 avatar
How do I programmatically create an order without deleting a profile?
eg flag

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' => ...
Score: 0
jackrabbithanna avatar
Update another line items quantity when line item updated
ke flag

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  ...

Score: 0
Aves2432 avatar
How to add conditions to display product variations in Drupal commerce?
eg flag

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. ...

Score: 1
Wyckham Seelig avatar
Product Attributes that do not require product variations
kr flag

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 ...

Score: 1
iamfredrik avatar
How to get product variation media file url using jsonapi?
us flag

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 ...
Score: 1
Codium avatar
Why custom condition is not containing parent entity?
us flag

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 ...

Score: 0
How to implement conditional shipping costs?
cn flag

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 ...

Score: 0
Michael Lechasseur avatar
drupalcommerce/project-base prohibits upgrade to Drupal 9.2.4
fi flag

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 ...

Score: 1
Michael Lechasseur avatar
Should I remove "Commerce Base" from site before an upgrade?
fi flag

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",

Remove listing in Upgrade Status module report

My original Drupal 8 install was with Composer u ...