When the UC Taxes module is activated I get the following error on every page with a Hotel Room content type:

Notice: Undefined index: display_price in uc_taxes_node_view() (line 98 of /homez.461/partyina/www/sites/all/modules/ubercart/uc_taxes/uc_taxes.module).
Notice: Undefined index: #value in uc_taxes_node_view() (line 98 of /homez.461/partyina/www/sites/all/modules/ubercart/uc_taxes/uc_taxes.module).
Notice: Undefined index: sell_price in uc_taxes_node_view() (line 101 of /homez.461/partyina/www/sites/all/modules/ubercart/uc_taxes/uc_taxes.module).
Notice: Undefined index: #value in uc_taxes_node_view() (line 101 of /homez.461/partyina/www/sites/all/modules/ubercart/uc_taxes/uc_taxes.module).
Notice: Undefined index: display_price in uc_taxes_node_view() (line 98 of /homez.461/partyina/www/sites/all/modules/ubercart/uc_taxes/uc_taxes.module).
Notice: Undefined index: #value in uc_taxes_node_view() (line 98 of /homez.461/partyina/www/sites/all/modules/ubercart/uc_taxes/uc_taxes.module).
Notice: Undefined index: sell_price in uc_taxes_node_view() (line 101 of /homez.461/partyina/www/sites/all/modules/ubercart/uc_taxes/uc_taxes.module).
Notice: Undefined index: #value in uc_taxes_node_view() (line 101 of /homez.461/partyina/www/sites/all/modules/ubercart/uc_taxes/uc_taxes.module).

Comments

Carlitta87’s picture

i have the same error same version.

larowlan’s picture

Project: Hotel Booking System for Ubercart » Ubercart
Version: 7.x-1.0-beta1 » 7.x-3.x-dev
Priority: Major » Normal

My guess is line 98 and line 101 of uc_taxes_node_view need to be wrapped in an if (!empty($node->sell_price['#value'])) (And display_price) respectively as not all modules that provide product types will set these values on the $node object

TR’s picture

sell_price is a required form element when creating a product through the UI, and a required database field when saving a product or loading a product using Drupal functions ('sell_price' field is NOT NULL, default 0.0). Does uc_hotel create the product programmatically but not set the sell_price on the hotel room content type?

My opinion is that if sell_price isn't set, the product type was created improperly. We simply can't add thousands of checks to see if all required product fields are set each and every place they are used in Ubercart. Right now the presence of sell_price is guaranteed by uc_product_load(), but if you're programmatically creating a $product object then it is your responsibility to ensure all the fields are present. It sure would be nice if Drupal mandated actual classes for node objects, so that the only way to create a product object for example would be $product = new Product(), which would result in a fully-initialized object containing all the necessary fields, but it doesn't. Even if Ubercart provided this class, there would be no way within Drupal to enforce its use.

Granted that some checks are necessary because of the structure of the PHP language and Drupal's use of E_NOTICE at run-time, but in this case it seems to be overkill. And the fact that uc_taxes doesn't generate these notices except for hotel content indicates to me that this should be addressed in the hotel content type. I don't know anything about the internals of uc_hotel, so I can't speculate on what needs to be done there.

larowlan’s picture

Hi Tim
uc_hotel has it's own node types (hook_node_info) that are registered as product types using hook_uc_product_types. It is probably the only module I know of that uses the Ubercart hooks other than uc_product.
There is no sell price field on these nodes.
The price is calculated based on the search results and set dynamically in hook_uc_cart_item/hook_uc_add_to_cart.

LR

larowlan’s picture

FWIW I'm already setting this in hook_load to prevent errors in the cart - so sell_price should already be set... (but notably not display_price) - the fact that the call is happening in hook_node_view for uc_taxes makes me think it's something to do with $node->content more so than $node->sell_price

    //this is for uc_cart errors
    $row->sell_price = $row->cost = $row->weight = $row->shippable = $row->weight_units = FALSE;

Will dig into the uc_taxes code when I get a chance

longwave’s picture

Title: Problem working together with UC_Taxes module » Tax errors when uc_hotel is installed
Component: Code » Taxes
Status: Active » Postponed

Postponed as this only seems to affect uc_hotel, please reopen if you use that module and can provide a patch.

TR’s picture

Untagging.

longwave’s picture

Status: Postponed » Closed (won't fix)

Not even sure what we can do here, never having used that module. Please reopen with more info if uc_hotel requires changes to Ubercart.

makokis’s picture

i get this error when create a "Room Type Hotel" with "hotel Booking System":

Notice: Undefined index: display_price en uc_taxes_entity_view_alter() (línea 114 de /home/a8412891/public_html/sites/all/modules/ubercart/ubercart/uc_taxes/uc_taxes.module).
Notice: Undefined index: #value en uc_taxes_entity_view_alter() (línea 114 de /home/a8412891/public_html/sites/all/modules/ubercart/ubercart/uc_taxes/uc_taxes.module).

i shaw many people with that error.
exists any patch to correct this?

thanks in advance for your help

Drupal 7
Ubercart 3.x
Hotel Booking System 7.x-1.0-beta1

AlfTheCat’s picture

getting these error too. is there any hope of a fix?

twinsdz’s picture

Issue summary: View changes

Hi
I have also this error

Notice: Undefined index: display_price in uc_taxes_entity_view_alter() (line 114 of /home/diezwill/public_html/site/sites/all/modules/ubercart/uc_taxes/uc_taxes.module).
Notice: Undefined index: #value in uc_taxes_entity_view_alter() (line 114 of /home/diezwill/public_html/site/sites/all/modules/ubercart/uc_taxes/uc_taxes.module).