Percent Rate Shipping

Contrib type: 
Module
Status: 
Complete and working
Moderation: 
Limited approval
Latest version: 
1.0

Downloads

Compatibility: 
Ubercart 1.x

Clone of the core Ubercart "Flatrate" shipping quote module, modified to calculate shipping cost as a base rate plus percentage of the order total.

PreviewAttachmentSize
uc_percentrate-5.x-1.0.tar.gz4.02 KB
j0rd's picture
Offline
Getting busy with the Ubercode.
Joined: 07/16/2008
Juice: 453
Bug in this module should hook_cart_item() update $item->price

There's a minor bug I've found in this module.

Should hook_cart_item($op, &$item) update $item->price, this module *does not* apply percentages to that price.

To resolve this I am calling $items = uc_cart_get_contents() in uc_percentrate_quote($products,$defaults,$method) and matching my $items up with $products over an ID I have. This ubercart project is rather custom, so this will not be an issue for most people, but I believe the percent should be applied to the adjusted price.

My install is too customized to provide a patch for this, but I wanted to make you aware of the issue.

--
Freelance Web Design

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3229
Re: Bug in this module should hook_cart_item() update $item->pri

Hmm, I think the problem is outside this module. This module, like Flatrate (which it is cloned from), just uses the $products array passed to it by uc_quote, so you're saying in fact uc_quote is wrong, because this array contains the database values for price rather than the cart values?

<tr>.
Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6855
Re: Re: Bug in this module should hook_cart_item() update $item-

uc_quote gets product information from the cart or the order and then from the database. uc_cart_get_contents() calls hook_cart_item(), so the price field should be as up to date as possible. I don't see anything in quote or cart that would do otherwise.

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3229
Re: Re: Re: Bug in this module should hook_cart_item() update $i

I certainly want this module to do things the "right" way, it's just a question of what is right.

Yes, you should expect the uc_percentrate module to quote a shipping cost based on a percent of the cart total. But you should also expect the $products object to hold the correct price.

I think uc_percentrate has to rely on the data passed to it by uc_quote. Otherwise, every single shipping quote module is potentially doing the wrong thing when your module is enabled. From what Lyle is saying, and from my cursory glance at uc_quote.module, it appears uc_quote is calling uc_cart_get_contents() in order to fill the $products array, so hook_cart_item() should be called for each product.

It's not clear to me where the problem lies. Perhaps the hooks aren't being called in the order or when you expect them, or perhaps your module doesn't work the way you think - I just don't know. uc_percentrate is just too simple, I don't see how it could be doing the wrong thing by using the $product->price passed from uc_quote.

<tr>.
khalemi@drupal.org's picture
Offline
Joined: 12/31/2008
Juice: 9
Re: Percent Rate Shipping

i've made some modification of the script and posted it here
http://drupal.org/project/uc_minpercentrate

i'm still testing it for any bug before made a commit in drupal cvs. the module is working.