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

dawehner’s picture

Project: Views (for Drupal 7) » Ubercart
Component: Miscellaneous » Code

This seems to be an ubercart issue.

In general please use words to describe problems, they are much easier to figure out sometimes.

rhazor’s picture

Thank you for fast respond, I edited the message and explained in words.

longwave’s picture

Priority: Major » Normal
Status: Active » Postponed (maintainer needs more info)

How do you set the product or display price to be cost * sell price? This must be done in custom code?

rhazor’s picture

Category: support » bug
Status: Fixed » Postponed (maintainer needs more info)

Yes, there is a custom module for that. This is the .module code: [removed]

tr’s picture

Problem 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?

longwave’s picture

That 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.

longwave’s picture

Category: bug » support
Status: Postponed (maintainer needs more info) » Postponed

Support 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!

rhazor’s picture

I 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.

longwave’s picture

Did you clear cache after applying the patches?

rhazor’s picture

When I clear caches I get those errors on white screen and then its over.

rhazor’s picture

Okay 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.

wodenx’s picture

Drupal 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.

My custom module wasn't affected at all, the topics issue isn't fixed.

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.

rhazor’s picture

There's a new link to the code http://pastebin.com/xwJYVpWJ

rhazor’s picture

It 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.

wodenx’s picture

OK - 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:

function gold_uc_product_alter(&$node) {
  if ($node->type == variable_get('gold_product_class', '')) {
    $node->price = $node->price * todaysGoldPrice('XAU');
   }
}

Please note, however, that this patch is definitely not final, and thus this api may change.

rhazor’s picture

wodenx 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.

wodenx’s picture

If 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.

rhazor’s picture

Yes, 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:

    Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in EntityAPIController->load() (line 184 of 

sites/all/modules/entity/includes/entity.controller.inc).
    Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 354 of 

includes/entity.inc).
    Recoverable fatal error: Object of class stdClass could not be converted to string in DatabaseStatementBase->execute() (line 2139 of 

includes/database/database.inc).

Can't tell if I had that problem before applying patches.

wodenx’s picture

Are 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.

rhazor’s picture

Status: Postponed » Fixed

Yes, that fixed the problems. Now everything's working.

rhazor’s picture

Issue summary: View changes

updated

rhazor’s picture

Category: bug » support
Status: Postponed (maintainer needs more info) » Fixed

Nope, not fixed yet. Getting the new error when going to Checkout:

    Notice: Undefined offset: 0 in uc_checkout_pane_quotes() (line 691 of /public_html/coin/sites/all/modules/ubercart/shipping/uc_quote/uc_quote.module).
    Notice: Undefined offset: 1 in uc_checkout_pane_quotes() (line 695 of /public_html/coin/sites/all/modules/ubercart/shipping/uc_quote/uc_quote.module).
    Notice: Undefined index: in uc_checkout_pane_quotes() (line 697 of /public_html/coin/sites/all/modules/ubercart/shipping/uc_quote/uc_quote.module).
    Notice: Undefined offset: 1 in uc_checkout_pane_quotes() (line 699 of /public_html/coin/sites/all/modules/ubercart/shipping/uc_quote/uc_quote.module).
    PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect decimal value: '' for column 'amount' at row 1: INSERT INTO {uc_order_line_items} (order_id, type, title, amount, weight, data) 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); Array ( [:db_insert_placeholder_0] => 12 [:db_insert_placeholder_1] => shipping [:db_insert_placeholder_2] => [:db_insert_placeholder_3] => [:db_insert_placeholder_4] => 1 [:db_insert_placeholder_5] => N; ) in drupal_write_record() (line 6888 of public_html/coin/includes/common.inc).

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?

rhazor’s picture

Status: Fixed » Active
tr’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

fixed