Basically, I created a new shipping type called 'Delivery' to go along with 'Small Package' by creating a small module with the following code:

function uc_custom_shipping_type(){
  $weight = variable_get('uc_quote_type_weight', array('customer_delivery' => 0));

  $types = array();
  $types['customer_delivery'] = array(
    'id' => 'customer_delivery',
    'title' => t('Delivery'),
    'weight' => $weight['customer_delivery'],
  );
  
  return $types;
}

So this creates for me a new shipping type called 'Delivery'

Now, I set Delivery to be the store default shipping type in Store > Configuration > Shipping Quote Settings.

I then created 2 Flatrate quotes 'Delivery quote' and 'Postage' and related them to our 2 types as follows using workflow-ng:

If order contains a product with shipping type 'Delivery' => Assign 'Delivery quote' quote
If order does not contain a product with shipping type 'Delivery' => Assign 'Postage' quote

This all works wonderfully well: as long as I explicitly mark 'Delivery' as 'Default product shipping type' in the product edit form, I get my 'Delivery quote' whenever the product is included, even if it is mixed up with other products.

However, if I leave it at the in the product edit form (which is set to delivery) then I get the 'Postage' quote. Debugging indicates the product indeed has the 'Delivery' shipping type, but somewhere in workflow or quote it is not getting picked up.

(ps: congratulations on a wonderful module. My client, who is by no means technical, is getting great joy from using it. In fact that's kind of the problem; his enthusiasm is such that he's gone and added 400+ products already, so I'd kind of like the defaults to hold :) )

CommentFileSizeAuthor
#3 quote_type_condition.patch575 bytesIsland Usurper
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nirbhasa’s picture

the phrase in the second last paragraph should read: 'if I leave it at the 'Store Default' in the product edit form'

I had it in angle brackets and they got stripped. boo.

nirbhasa’s picture

Version: 5.x-1.6 » 5.x-1.7

Upgraded to 1.7; issue remains

Island Usurper’s picture

Assigned: Unassigned » Island Usurper
Status: Active » Fixed
FileSize
575 bytes

It looks like I had forgotten the API I had written in that module. The shipping type condition uses the wrong function to get the product's shipping type, so it isn't getting the default value when the product is set to use the default. Patch to fix.

nirbhasa’s picture

It worked, thank you!

nirbhasa’s picture

Title: Errors with new custom shipping order » Errors with new custom shipping type

changing title for the benefit of others with the same issue

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

kimmeehh’s picture

"Now, I set Delivery to be the store default shipping type in Store > Configuration > Shipping Quote Settings."

This is not possible. I have still only one option.
I made a module: with just the above code in the .module file, and the name and description in the .info file. Moduke is on the same level as ubercart.

Even with the patch, i still do not get a second shipping type. Not when creating a new product, nor when setting rules.

I am doing something wrong, but what?
Using UC 1.7 and Drupal 5.18

Any help is appreciated, i am kind of stuck here :(

nirbhasa’s picture

The function should be called {mymodule_name}_shipping_type - in my case my module was called uc_custom