Drupal Commerce Issue Queue

Create a service for determining variation availability

Wed, 06/24/2015 - 04:35

Followup to #2506163: Complete the initial product architecture.

Also needed for the add to cart form.

Commerce 1.x has no API for determining if a product is available. This means that modules such as commerce_stock need to register various different validation handlers (on the different add to cart forms) to be able to prevent a product from being added to the cart.
There's also the "Set the product price to NULL from a pricing rule" way of doing it, but it's bad DX.

- AvailabilityCheckerInterface (with a check($variation, $quantity) method) -> implemented by services tagged with commerce_product.availability_checker.
The check returns TRUE (available), FALSE (not available), or NULL (no opinion).
We should replace these with value objects later, allowing the return values to be expanded in the future without breaking BC.
- AvailabilityManager service (with the same check method) which gets all of the registered checkers, runs them until it gets a FALSE.
One FALSE means that the variation is not available. This service can maintain a static cache of results.

These classes need to live in commerce_order. We'll make it product entity type agnostic in one of the iterations.

The add to cart form will check the availability of the selected variation, disable the add to cart button if the variation is not available.
It will repeat the same check when the form is submitted.

Use cases:
- Deny availability if the variation "available on" date is before the current date
- Deny availability if the variation is out of stock (commerce_stock or custom stock check)

Categories: Issue Queues

Commerce Order context in panles

Wed, 06/24/2015 - 04:17

I would like to get the context of a customers latest order into panels.

I have tried adding the relationship "Commerce Order from User (on commerce_order.owner)" but this does not give any results.

I have also tried creating a context view of type Commerce Order and added this as context to the panel but panels does not recognise this in the same way as it does nodes and terms.

Categories: Issue Queues

Create a service for getting enabled product variations

Wed, 06/24/2015 - 04:07

Followup to #2506163: Complete the initial product architecture.

For the add to cart form we need a way to get all enabled variations of a product.

This means getting the variation ids referenced by the product, loading only the enabled ones (status = TRUE), then running an event on them (COMMERCE_PRODUCT.FILTER_VARIATIONS) to get the final list.

This should be implemented in a VariationManager (using the variation storage and the entity dispatcher as dependencies), with a getEnabledVariations($product) method. This will allow the logic to be easily swappable.

Categories: Issue Queues

commerce_product_validate_sku() gives false positive when $sku starts with a comma

Mon, 06/22/2015 - 16:19

Take a look at how commerce_product_validate_sku() is written:

function commerce_product_validate_sku($sku) {
  // Do not allow commas in a SKU.
  if (strpos($sku, ',')) {
    return FALSE;

  return TRUE;

With it being written this way if $sku starts with a comma it will give a false positive.

For example:

$invalidSku = ',sku';
$anotherInvalidSku = ',,,,,,';

if(commerce_product_validate_sku($invalidSku) {
  echo $invalidSku . " is valid";
else {
  echo $invalidSku . " is invalid";

if(commerce_product_validate_sku($anotherInvalidSku) {
  echo $anotherInvalidSku . " is valid";
else {
  echo $anotherInvalidSku . " is invalid";


,sku is valid
,,,,,, is valid

Clearly this shouldn't be happening.

Proposed resolution

Change the implementation of commerce_product_validate_sku() so that it will not return any false positives.

Categories: Issue Queues

Best way to setup jewelry shop in commerce

Mon, 06/22/2015 - 15:28

WHat is the best way to setup jewelry store?

We have many jewelry items,2000 to be exact.

We have similar design rings, with different stones, lets say one type or ring has stones liek Ruby, Amethyst, Zircon ...it can be 10 variations.

So if we create product variations for each stone it will take forever..

Lets say I have a ruby ring with sku 110R and I want to add variations with different stones, like for example

110am --amethyst stone
110zir - zirconia stone

I would have to add 10 different variations if we have 10 different stones right?

And do that for each content type right.

For example
I create second product

110am zirconia ring
and again I have to add 10 different variations

so to add 10 content type rings, I would need to add like 100 variations alltogether, for each content type 10 variations, right?

Is there an easier way to do this

Also we would have 4 differnt sizes for each ring, so that would be like 100 x 4, 400 different variations to add manually for 10 content types

I really need help on this one, any idea how to do this quicker than adding 400 variations?

Categories: Issue Queues

Notice: Undefined index: field_definition in Drupal\commerce_price\Plugin\Field\FieldWidget\PriceDefaultWidget::create

Sun, 06/21/2015 - 20:30

Happens when adding a new product via the admin, and stops simpletest from working.

Notice: Undefined index: field_definition in Drupal\commerce_price\Plugin\Field\FieldWidget\PriceDefaultWidget::create() (line 85 of /home/josh/web/commercetests/modules/commerce/modules/price/src/Plugin/Field/FieldWidget/PriceDefaultWidget.php).

Categories: Issue Queues

Media tags in commerce_checkout_completion_message

Sun, 06/21/2015 - 18:18

Due to the fact that Media uses replacement tags similar to that of Tokens, and that token_replace() is run over the commerce_checkout_completion_message before check_markup, and as token_replace() is clearing any un-processed tokens, Media tags are not getting replaced.

Obviously changing the behaviour would effect everyone with Commerce currently in place, so it's less than ideal. Ideally Media would use a compliant Token format or a drastically different format, but that is not currently the case.

As a workaround on my clients site I have run check_markup() over the data before it gets processed by Commerce, but it's possible others may come across this issue.

Categories: Issue Queues

Inline errors look terrible on the price field

Sun, 06/21/2015 - 14:42

Inline errors landed in core recently. When combined with the price field, the result is not good, because the currency selector is pushed to the next row (instead of the error itself being below both the amount/currency and description rows).

We need to see if we can move the placement of the error (or tweak the css to achieve what we need), or move the error to the parent form (making sure it doesn't go more than 1 level above, to account for Inline Entity Form).

Categories: Issue Queues

The store email isn't validated

Sun, 06/21/2015 - 13:36

Go to admin/commerce/stores/add, enter "test@", save. No error.

Store::baseFieldDefinitions() defines a "mail" field, but the "Email" constraint isn't added.

Solution: Add the Email constraint to the mail field, the same way the ProductSku constraint is added to the product sku field.
Also add a test case confirming that a store with an invalid email can't be saved.

Categories: Issue Queues

Commerce Payment - PaymentTransaction Entity has the incorrect edit-form, delete-form

Sun, 06/21/2015 - 04:43

This should be linking to the URL instead of the entity, as per https://www.drupal.org/node/2382937

Categories: Issue Queues