How to specify default product in product display?

My issue is that I have created all my products in Commerce and created a product display, all the different options for the product are given through a couple of drop down select lists.

I want the default to be the lowest price and I have achieved this in part by using the method of creating a module which uses hook form alter and changes the default value for each select list, however the price doesn't update. It still shows the original price until a new selection is made in one of the select lists.

I read elsewhere that the SKU defines the default product in the display yet I have tried to manipulate this by changing the SKU and nothing changes.

Someone else must be having this issue somewhere, can we figure something out... Thanks

Posted: Jun 19, 2014


Joeuk on August 12, 2014

Really need a solution for this... I have tried altering the SKU code as it seemed as if the default item in the product display was being defined by the alphabetic order of the SKU's

But to no avail

Joeuk on September 23, 2014

The solution to this was to create a custom module that uses hook_commerce_product_reference_default_delta_alter

Here is what worked for me

function hook_commerce_product_reference_default_delta_alter(&$delta, $products) {
  foreach (
$products as $key => $product)  {
    if (!isset(
$currentlowest)) {
$delta = $key;
$currentlowest = $product->commerce_price[und][0][amount];
    } elseif (
$product->commerce_price[und][0][amount] < $currentlowest) {
$currentlowest = $product->commerce_price[und][0][amount];
$delta = $key;  

joshmiller Josh Miller on September 24, 2014


Or, depending on your product reference widget, the order of the products referenced determines which is "default."

I actually demonstrate this in a recent video, which I have linked here to jump you in to the relevant part:


"PROD-03" is default, which is large ... if I had wanted to make small default, I simply would have had to move the SKUs around to make the first one small.


Joeuk on September 24, 2014

Hi Josh,

I see what you mean, would this only work with the auto complete widget? Because I have many products per display. It is not ideal to do this, this is why I wrote the custom module to do this on the fly.

But one issue I have encountered with this is related to having a file or image upload line item. The problem being that when adding a product to cart when there is an upload line item, unless you manually change one of the drop down select list attributes on the product display, the original default product is still added to cart. By original default I mean the one that was defaulted before I added the above code.