Originally Posted by
mc12345678
Couple of things.
In future, recommend enclosing code in code tags: [CODE][/CODE]
To make it easier to read and as necessary for testing to copy and paste the code.
Second, would be to capture the condition of $products before the foreach loop. This should dump them to a debug file:
Code:
trigger_error('$products array before loop: ' . print_r($products, true), E_USER_WARNING);
One thing that looks "unusual" is the adjustment of $option if your search string is found, because the remaining string returned will start with 2 underscores that then when cast to integer will result in 0 instead of the integer that is at the end of that triple underscore string. But without seeing the data of this home brew code, there's little way to identify why a single character is presented instead of the expected string. The issue likely is related back to the assignment that was made to create the data being parsed.
Sorry . here is the code
Code:
trigger_error('$products array before loop: ' . print_r($products, true), E_USER_WARNING);
foreach ($products[$i]['attributes'] as $option => $value) {
/*
//clr 030714 Determine if attribute is a text attribute and change products array if it is.
if ($value == PRODUCTS_OPTIONS_VALUES_TEXT_ID){
$attr_value = $products[$i]['attributes_values'][$option];
} else {
$attr_value = $attributes->fields['products_options_values_name'];
}
*/
$tmp_option = $option;
$pos = strpos($option, '___');
$measure_name = '';
if ($pos !== false) {
$measure_name = substr($option, 0, $pos) . ' - ';
$option = substr($option, $pos+1);
}
$attributes_query = "select popt.products_options_name, poval.products_options_values_name,
pa.options_values_price, pa.price_prefix, popt.products_options_type
from " . TABLE_PRODUCTS_OPTIONS . " popt,
" . TABLE_PRODUCTS_OPTIONS_VALUES . " poval,
" . TABLE_PRODUCTS_ATTRIBUTES . " pa
where pa.products_id = '" . (int)$products[$i]['id'] . "'
and pa.options_id = '" . (int)$option . "'
and pa.options_id = popt.products_options_id
and pa.options_values_id = '" . (int)$value . "'
and pa.options_values_id = poval.products_options_values_id
and popt.language_id = '" . (int)$_SESSION['languages_id'] . "'
and poval.language_id = '" . (int)$_SESSION['languages_id'] . "'";
$attributes = $db->Execute($attributes_query);
if($attributes->recordCount() == 0) {
$attributes_query = "select products_options_name, products_options_type
from " . TABLE_PRODUCTS_OPTIONS . "
where products_options_id = '" . (int)$option . "'
and language_id = '" . (int)$_SESSION['languages_id'] . "'";
$attributes = $db->Execute($attributes_query);
}
//clr 030714 Determine if attribute is a text attribute and change products array if it is.
if ($value == PRODUCTS_OPTIONS_VALUES_TEXT_ID){
$attr_value = $products[$i]['attributes_values'][$tmp_option];
} else {
$attr_value = $attributes->fields['products_options_values_name'];
if($attr_value==''&& $tmp_option!='attributes_updated') {
$attr_value_query = $db->Execute("select * from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id=" . $value);
$attr_value = $attr_value_query->fields['products_options_values_name'];
}
}
if(!empty($products[$i]['measurement_profile_id'])) {
$custom_profile_relate = $db->Execute("select product_measurement_options_name, products_options_append from " . TABLE_PRODUCTS_MEASUREMENT_OPTIONS_RELATE . " pmor join " . TABLE_CUSTOMERS_MEASUREMENTS_OPTIONS_RELATE . " cmor on pmor.options_relate_id = cmor.options_relate_id where cmor.measurements_info_id = " . $products[$i]['measurement_profile_id'] . " and cmor.products_options_id = " . (int)$option);
$relate_name = '';
if($custom_profile_relate->fields['products_options_append'] == 1) {
$relate_name = $custom_profile_relate->fields['product_measurement_options_name'];
if($relate_name != '') $relate_name = '-' . $relate_name;
}
}
$this->products[$index]['attributes'][$subindex] = array('option' => $measure_name . $attributes->fields['products_options_name'] . $relate_name,
'value' => $attr_value,
'option_id' => $tmp_option,
'value_id' => $value,
'prefix' => $attributes->fields['price_prefix'],
'price' => $attributes->fields['options_values_price']);
$this->notify('NOTIFY_ORDER_CART_ADD_ATTRIBUTE_LIST', array('index'=>$index, 'subindex'=>$subindex, 'products'=>$products[$i], 'attributes'=>$attributes));
$subindex++;
}
}
IF the version of php is 7.0 and below no dump file and value shows fine.
if php version 7.1 and 7.2 then a log file is generated which is as follows
[21-Jan-2019 03:40:26 UTC] Request URI: /index.php?main_page=checkout_confirmation, IP address: 45.249.82.116
#1 trigger_error() called at [/includes/classes/order.php:553]
#2 order->cart() called at [/includes/classes/order.php:34]
#3 order->order() called at [/includes/modules/pages/checkout_confirmation/header_php.php:63]
#4 require(/includes/modules/pages/checkout_confirmation/header_php.php) called at [/index.php:36]
--> PHP Warning: $products array before loop: Array
(
[0] => Array
(
[id] => 3718:cd24a9cd3ff7e2cd43358b5c014ec7ee
[category] => 1
[name] => Archer Blue Light Wash Jeans
[model] => R Naps - Hb
[image] => jeans/archerblueltwashjeans.jpg
[price] => 59
[quantity] => 1
[weight] => 2
[final_price] => 59
[onetime_charges] => 0
[tax_class_id] => 0
[measurement_price] => 0
[measurement_arributes] => Array
(
)
[attributes] => Array
(
[attributes_updated] => 1
[20] => 20
[290] => 7220
[84] => 362
[283] => 6530
[1] => 0
[2] => 7
[3] => 3236
[8] => 0
[5] => 0
[6] => 0
[23] => 0
[42] => 0
[7] => 0
[87] => 0
[24] => 0
)
[attributes_values] => d 4424 91 1 1
[products_priced_by_attribute] => 0
[product_is_free] => 0
[products_discount_type] => 0
[products_discount_type_from] => 0
[products_measurement_type] => 1
[measurement_profile_id] => 79367
[products_options_values_measurement] => 1
[products_is_remake] => 0
[is_valid_remake] => 1
)
)
in /includes/classes/order.php on line 553.
The attributes which shows like
[attributes_values] => d 4424 91 1 1
when in 7.0 the value is
[attributes_values] => Array
(
[1] => diptimoy
[8] => 46
[5] => 40
[6] => 43
[23] => 9.5
[42] => 15.5
[7] => 27.5
[87] => 17.5
[24] => 16
)
Thanks in advance.
Bookmarks