I have created a product with a variable price however the price entered by the user is not reflected in the item in the shopping cart, it only shows the default price you set for the product. The correct price is shown in the subtotal and order total sections of the checkout and will process for the correct total but it's not giving users the visual reminder that their amount has updated.

thanks
Bernie

Comments

oromix’s picture

I have the same situation... default installation of Ubercart, using one attribute on the product. The entered amount in the variable price does not display in either the cart or the checkout screen except for the subtotal and total amounts on the checkout screen.

oromix’s picture

StatusFileSize
new8.77 KB

I made a patch to fix this issue. The price of the item was getting correctly set, however the "display_price" was not.

Please test and let me know if it doesnt work.

mcfilms’s picture

Hi oromix,

The patch does not quite work. I get the following error when I try and patch uc_varprice 7.x-1.0-rc2:

--------------------------
Computer:~/Desktop/VARPRICE/uc_varprice me$ patch < uc_varprice_cart_display.patch
patching file uc_varprice.module
Hunk #1 succeeded at 223 (offset -3 lines).
can't find file to patch at input line 18
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/sites/all/modules/custom/custom_prospera/custom_prospera.module b/sites/all/modules/custom/custom_prospera/custom_prospera.module
|index ade5c7b..3ecee5b 100644
|--- a/sites/all/modules/custom/custom_prospera/custom_prospera.module
|+++ b/sites/all/modules/custom/custom_prospera/custom_prospera.module
--------------------------
File to patch:
--------------------------

So the patch is looking to integrate with your custom_prospera module. When I try and run this partially patched file on the server I get the same results. The default price id the only price seen in the shopping cart.

PS -- Now that I look at that patch closer, I suspect that you uploaded the wrong patch.

spoonbow’s picture

Any progress/updates on this? Having the same problem here...

Thanks!
Matt

UPDATE - Looked at the patch file, found the pertinent code ($item->display_price = $item->data['varprice'];) and inserted it into uc_varprice.module at line 226. Prices now display correctly in the cart. Updated code snippet:

/**
 * Implements hook_uc_cart_item().
 */
function uc_varprice_uc_cart_item($op, $item) {
  // When the cart product is being loaded...      
  if ($op == 'load') {
    // If the product has a variable price set...
    if (!empty($item->data['varprice'])) {
      // Update the cart item's price to the entered price value.
       $item->price = $item->data['varprice'];
       $item->display_price = $item->data['varprice'];
    }
  }
}
mcfilms’s picture

Status: Active » Needs work

Hey Spoonbow, thank you for posting that. It works perfectly.

I set this aside because I thought the patch was for the wrong module. I'm so glad you did a little more investigating. It would be nice if we could get this rolled into the next version of UC Variable Price. But changing the status to "reviewed and tested" might lead the maintainer to believe the patch is good to go. So I set it to "Needs Work." (?)

Oh, also, thanks to oromix for digging through the module and finding the error in the first place.

Feet’s picture

I haven't reviewed it, but it has worked for me.
Cheers.
(I should learn how to review and test properly)

HorsePunchKid’s picture

Component: Miscellaneous » Code
Category: support » bug
Status: Needs work » Reviewed & tested by the community
StatusFileSize
new456 bytes

Here's a freshly rolled patch against 7x.-1.0-rc2. Works for me, makes sense, and is simple.

natuk’s picture

Works for me.

dquark3’s picture

Worked for me too. Without the patch, any entered amount was disregarded and subtotal showed 0.00.

Darkwaltz4’s picture

ubercart 7.x-3.0-rc4 deleted hook_uc_cart_item... uc_varprice_uc_cart_item should be replaced with:

/**
 * Implements hook_uc_product_alter().
 */
function uc_varprice_uc_product_alter($item) {
  // If the product has a variable price set...
  if (!empty($item->data['varprice'])) {
    // Update the cart item's price to the entered price value.
    $item->display_price = $item->price = $item->data['varprice'];
  }
}
Darkwaltz4’s picture

Priority: Normal » Critical
Status: Reviewed & tested by the community » Needs review
HorsePunchKid’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new937 bytes

I can confirm that Darkwaltz4's code in #10 works as I would expect. Attached is the same code in patch form.

jrust’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, patch applied.

Status: Fixed » Closed (fixed)

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