Closed (fixed)
Project:
Ubercart
Version:
7.x-3.0-rc3
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
29 Dec 2011 at 15:34 UTC
Updated:
16 Jan 2012 at 22:30 UTC
Sell Price/or Display Price in the products page/node is shown correctly as $288.44. I am trying to show same price via Views, using Fields and I get wrong values, not the actual final price, but the value entered into the Sell Price field in its Edit page.
Using Drupal 7.10 with latest Ubercart and Views (tried dev too).
(the thread was moved from Views issues to Ubercart)
Comments
Comment #1
dawehnerThis seems to be an ubercart issue.
In general please use words to describe problems, they are much easier to figure out sometimes.
Comment #2
rhazor commentedThank you for fast respond, I edited the message and explained in words.
Comment #3
longwaveHow do you set the product or display price to be cost * sell price? This must be done in custom code?
Comment #4
rhazor commentedYes, there is a custom module for that. This is the .module code: [removed]
Comment #5
tr commentedProblem is the Views handler for display_price takes the value directly from the database, after node_load($product), while modules which manipulate the display_price do it in hook_node_view() or some similar place which is bypassed by the handler. How is this dealt with when displaying prices including tax?
Comment #6
longwaveThat is what is being worked on in #1301430: Inclusive tax implementation is not flexible (attribute options) which would provide a neater implementation for the custom code here, and should even allow the calculation to be done in Rules instead of a custom module.
Comment #7
longwaveSupport request as this is custom code, postponed as it is waiting for the above linked patch to land - which will probably need changes to this custom code. Testing of that patch would be appreciated!
Comment #8
rhazor commentedI tried to apply few patches from that link to my site but I get errors with uc_cart/uc_order controller files (which are created after applying the patch). I get errors related with Entity module and includes/common.inc saying that can't find those controllers or classes or something like that, and I had to re-import my .sql database, because patches totally ruined my site.
Comment #9
longwaveDid you clear cache after applying the patches?
Comment #10
rhazor commentedWhen I clear caches I get those errors on white screen and then its over.
Comment #11
rhazor commentedOkay so I cleared cache after every single file I patched and uploaded one by one to the server. Everything was working fine until patched the uc_order.info and uc_order.info.inc and I get:
Notice: Undefined index: label in entity_views_field_definition() (line 165 of /public_html/sites/all/modules/entity/views/entity.views.inc).The notice disappears after refreshing the page (appears only when clearing cache). Last file to be patched was uc_taxes.test and it was successful.
I used 1301430-product-variant-65.patch patch on todays ubercart-7.x-3.x-dev.zip Website runs fine, but I get that notice message I mentioned above. So I guess I'll just roll back again.
My custom module wasn't affected at all, the topics issue isn't fixed. The only thing that has changed that the custom price also dropped from displaying at Shopping cart block and now it's displaying the Sell price field value (same issue with Views Price display field). The custom generated price (Cost field * Sell Price) is displayed correctly only at the products page/node. Views fields Sell price and Display price shows same value entered into the Sell price field.
My idea is to show the calculated price of Cost * Sell price fields via Views (and after the patch via Cart block), the same price which is correctly shown in the products page.
UPDATE:
I just noticed that I skipped the new files created after the complete patching, the uc_cart.controller.inc and uc_order.controller.inc. After uploading those two and clearing the cache I get:
DOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'UcOrderController-class' for key 'PRIMARY': INSERT INTO {registry} (name, type, filename, module, weight) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4), (:db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => UcOrderController [:db_insert_placeholder_1] => class [:db_insert_placeholder_2] => sites/all/modules/ubercart/uc_order/uc_order.controller.inc [:db_insert_placeholder_3] => uc_order [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => UcOrderProductController [:db_insert_placeholder_6] => class [:db_insert_placeholder_7] => sites/all/modules/ubercart/uc_order/uc_order.controller.inc [:db_insert_placeholder_8] => uc_order [:db_insert_placeholder_9] => 0 ) in _registry_parse_file() (line 179 of /public_html/includes/registry.inc).On a blank page.
Comment #12
wodenx commentedDrupal and Entity API can be tetchy when it comes to updating entity info. See #996236: drupal_flush_all_caches() does not clear entity info cache. I'm fairly certain, however, that patching each file one-by-one and clearing the caches between can't work - the files have interdependencies. The last error you received implies that your class registry wasn't properly cleared - or that uc_order.module wasn't properly patched. However, when I try this on a clean drupal install, I don't have any issues.
Something to try: revert to pre-patch state. apply complete patch. use drush or dev "execute php" block to execute "entity_info_cache_clear();" - then clear all caches as usual.
You'll almost certainly have to modify your custom module to take advantage of the changes introduced by #1301430: Inclusive tax implementation is not flexible (attribute options). Hard to tell, though, without seeing your code - and your link from #4 doesn't seem to work.
Comment #13
rhazor commentedThere's a new link to the code http://pastebin.com/xwJYVpWJ
Comment #14
rhazor commentedIt works! With the 1301430-product-variant-68.patch and the entity_info_cache_clear(); everything is fixed now! And not just that, my custom calculated prices are shown via Views too! Which is awesome!
However the problem is fixed like described at the topic of this issue, it has moved to the Cart block which shows Total $. It was working before patching and outputing the calculated prices of Cost * Sell price, but looks like its pulling out the exact values from the Sell price field like Views problem did :/ Maybe I had to skip some files from patching.
Comment #15
wodenx commentedOK - to use the patch (once you get it installed), you'll need to replace your implementations of hook_uc_cart_item() and hook_node_view() with a single implementation of the new hook_uc_product_alter() - something like this:
Please note, however, that this patch is definitely not final, and thus this api may change.
Comment #16
rhazor commentedwodenx what i mentioned on my previous post means that not only the Cart block is pulling out the Sell price (not the Cost*Sell price sum), but also in the Checkout I get same problems. Which means customers can buy items for fake prices.
It was ok before patching, but had that issue with Views, and after patching its fixed, the issue moved to the Cart block and the Checkout :/
So I don't know if I need to update my custom module since I think these problems are generated somewhere inside the Ubercart files. Without editing my custom module the prices are shown correctly via views after the patch.
Maybe I had to skip some files from patching or something.
Comment #17
wodenx commentedIf you want to use the patched version, you will have to make the changes I suggested - the old hook_uc_cart_item('load', ... ) has been removed as part of the patch - that's why the price is not shown correctly in the cart block or at checkout. The price IS shown correctly in views and on the product page because the alteration you make in hook_node_view() is picked up there - however, if you implement both hook_node_vew() and hook_uc_product_alter(), to make the same alteration, your change will apply twice.
Comment #18
rhazor commentedYes, you were right, I deleted the old implementations and replaced with your code. After flushing the Cache everything works now perfectly as I wanted. Thanks to you good people doing this perfect job. All prices everywhere are working fine now.
But I got another issue with entity module. I don't know if its related to these changes and patches but this touches Ubercart and Entity. When I try to submit order payed by Bank or Check I get this now:
Can't tell if I had that problem before applying patches.
Comment #19
wodenx commentedAre you using the latest DEV of 'entity' module. If so, please see #1388984: array_flip() error when rendering invoices using Entity 7.x-1.x-dev.
Comment #20
rhazor commentedYes, that fixed the problems. Now everything's working.
Comment #20.0
rhazor commentedupdated
Comment #21
rhazor commentedNope, not fixed yet. Getting the new error when going to Checkout:
All I did, just enabled some extra Ubercart modules trying to sort out how to control Stocks in Ubercart, still can't find the settings, only the stock notifications. But how to set stock quantity and display it in a product page?
Comment #22
rhazor commentedComment #23
tr commentedProblems with #1301430: Inclusive tax implementation is not flexible (attribute options) should be addressed in that issue.
Comment #24.0
(not verified) commentedfixed