Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
4

you could do something like this: use Drupal\Core\Form\FormStateInterface; use Symfony\Component\HttpFoundation\RedirectResponse; function MYMODULE_form_alter(&$form, FormStateInterface $form_state, $form_id) { if (strpos($form_id, 'commerce_order_item_add_to_cart_form_commerce_product') !== false) { $form['actions']['submit']['#submit'][] = '...


4

You need to unset the #value on your image_buttons: $item['#type']='image_button'; $item['#src']='sites/all/themes/mytheme/images/trash.svg'; $item['#alt']='Remove'; unset($item['#value']); // this line here The line item that is deleted is determined by the #triggering_element in your $form_data. This element is determined by a function ...


3

Remove the event subcriber service from the container: my_module/src/MyModuleServiceProvider.php namespace Drupal\my_module; use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\DependencyInjection\ServiceProviderBase; /** * Remove the foo event subscriber. */ class MyModuleServiceProvider extends ServiceProviderBase { /** * {@...


3

The easiest way to do this is just create a view using a page display if you did not know you can use dynamic replacement in your views page urls aka "This view will be displayed by visiting this path on your site. You may use "%" in your URL to represent values that will be used for contextual filters: For example, "node/%/feed". If needed you can even ...


3

If the data about a product are not available when processing a "line item", you can make them available. To do so, use a technique similar to what is explained in my answer to "How to access commerce_product field of line-items using Rules to flag the Commerce Product?", which includes a Rules Component that looks like so: { "...


2

I believe the Most efficient and Fast way to get all the Orders is $orders = \Drupal::entityTypeManager()->getStorage('commerce_order')->loadMultiple(); if you want to get the Completed Orders then you can use the loadByProperties() as like: $orders = \Drupal::entityTypeManager()->getStorage('commerce_order')->loadByProperties(['state' => '...


2

This is because you've got more than 1 variation on a product. The v parameter allows you (and drupal commerce) to directly link to the product page with the correct variant set as the selected one For example you have "t shirts" product with variations for colour. You might want to link directly from the product listing page/cart/anywhere else to a ...


2

If you take a look at this page, you can see that what comes out of the box is that you create a seperate product variation for the recurring products and then create seperate products. Instructions from the docs: Download and install the Commerce Recurring Framework and Advanced queue Drupal modules. Create a variation for the recurring ...


2

Instead of unsetting the #value property (which works, but I find it personally counter-intuitive), you could try setting it by using the form_type_image_button_value() function. As an example: function my_custom_module_form_views_form_commerce_cart_form_default_alter(&$form, &$form_state, $form_id) { if (!empty($form['edit_delete'])) { ...


1

In your "submitForm" method write below code: $form_state->setRedirect('<front>'); return; To redirect you can also use the following code: //after the namespace use Drupal\Core\Url; //In your "submitForm" $url = Url::fromRoute('<front>'); $form_state->setRedirectUrl($url); To redirect you can also use the following code: //after the ...


1

It will help if you add the rule that you have added. Also if you think it's a complex rule to be applied, you can apply the discount in the checkout page rather than before that without using the rules itself. In other places just display the 1pcs price with the discount applied.


1

Install the Commerce Bulk module and create or change your SKUs in bulk. Also, I'd recommend to check if you have any orphaned variations (no parent product) which are legal in Drupal Commerce 2.x but has no any UI to manage them. If you are sure that those should not exist on your site then just delete them all: https://www.drupal.org/project/commerce_bulk/...


1

This doesn't answer your question specifically but is an alternative. If it's the standard commerce email you could go to "Commerce > configuration > Orders > Order types" and within each order type you can control to "Email the customer a receipt when an order is placed"


1

It's safe as long as you don't have any products. We need to change the logic in Commerce so that it checks for existence of product entities, instead of just checking whether the product type is new. Continued in your issue: https://www.drupal.org/project/commerce/issues/3014686


1

We don't have a "cancel" or "reverse" feature right now, but it would be worth a feature request in the State Machine queue. The main thing you / we'll need to overcome is what to do in the event a transition in progress has already saved data, triggered 3rd party services, etc. Presumably, there are certain things that should prevent a transition from being ...


1

Install the https://www.drupal.org/project/commerce_xquantity and set the max property on the /admin/commerce/config/order-item-types/YOUR_TYPE/edit/form-display/add_to_cart page to 1 or any other value. So, once at a time clicking on the Add to cart button or editing quantity on the /cart page a customer can't add more than max. But if you want overall to ...


1

For the benefit of anyone who comes looking, the answer is that the fields need to be added to the order item type. Commerce sees each product as a sort of Platonic object and stamps out instances as order items -- think line items. You can add fields to this. Whee. Unfortunately, you can't reference Paragraph entities because, as ridiculous as it seems to ...


1

There are multiple solutions to this problem: Cron manager One is indeed to use a cron manager module. I think you would need Feeds Ultimate Cron for this. This solution would require you though to guess when the first import is completed. Rules Using the Rules action 'Execute feeds importer' (requires latest dev of Feeds 7.x-2.x or the patch from https://...


1

To solve this issue, I needed to add one payment method that is not "Offsite" the error message is just very misleading.


1

Maybe have a look at affiliate systems to see if they can guide you in the direction of a solution, e.g. https://www.drupal.org/project/commerce_affiliate. The issue here is that you haven't defined what your actual end goal is - if you simply want to know what the 80/20 split of the sale value is, you can just use https://www.drupal.org/project/...


1

install views rules module, make a views-rules of orders, you will need OID as a contextual filter, add it as allways, then in middle column, in parameters settings set your OID as:integer, add all fields/attributes you wish, now in middle column settings, set your fields/attributes values as text, choose 'use rendered output'. Then in your send-email-to-...


1

<?php /** * Implements hook_token_info(). */ function mymodule_token_info(){ $info['tokens']['commerce-order']['line_item_detail'] = array( 'name' => t('Line Item Product Detail List'), 'description' => t('List all the Product Line Item Detail of the order') ); return $info; } /** * Implements hook_tokens(). */ ...


1

When product sell prices are calculated via Rules, they are done so in the context of either a temporary line item (for products not in the cart) or the line item on an order (for products in the cart). This means you can check to see if the commerce-line-item:line-item-id is empty or not using something like the "Data value is empty" condition. In your case,...


1

Seems now you know the answer :) https://www.drupal.org/project/commerce_bulk/issues/3023651 BTW, thank you for your contribution to the module!


1

If someone need to do the same thing as me, finally I compare the dates of the coupon with the order date, so if a user use a coupon on an order, when I edit it even if the coupon is expired the order still have it. Here is how I proceed : First I rewrite the condition 'commerce_discount_date_condition' : function mymodule_rules_condition_info_alter(&...


1

Drupal Commerce has duplicate entities because a product is referenced from multiple variations, any field you add to a variation type will find multiple duplications in your view most notably in images but could be any field in example t-shirt size. An easy way to remove these is to set in your view: FILTER CRITERIA Product: Variations:delta (= 0)


1

Try this: use Drupal\commerce_payment\Entity\Payment; $payments = \Drupal::entityQuery('commerce_payment') ->condition('order_id', $order->id()) ->execute(); foreach ($payments as $value) { $payment = Payment::load($value); $payment->setState('completed')->save(); }


1

This has recently been implemented in Fire generic events when transition are applied [#2832415].


1

Try the Commerce Extended Quantity module price adjustments for a current quantity in the cart: https://github.com/drugan/commerce_xquantity#quantity-price-adjustments


1

The https://www.drupal.org/project/commerce_currency_resolver module will help you do this.


Only top voted, non community-wiki answers of a minimum length are eligible