From c425ef6ad46964395ed2b04caa3a2edad72e6ae7 Mon Sep 17 00:00:00 2001 From: Kiran Date: Tue, 2 Jun 2015 14:32:51 +0530 Subject: [PATCH] [#590] - Product option Price doesn't get saved once logged in as customer. Fixed checkout confirmation and checkout success option display. --- catalog/includes/classes/shopping_cart.php | 20 ++++++++++++++++++- .../checkout/checkout_confirmation.php | 3 ++- .../content/checkout/checkout_success.php | 3 ++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/catalog/includes/classes/shopping_cart.php b/catalog/includes/classes/shopping_cart.php index c0b074fcb..7c00389fe 100644 --- a/catalog/includes/classes/shopping_cart.php +++ b/catalog/includes/classes/shopping_cart.php @@ -190,7 +190,25 @@ public function synchronizeWithDatabase() { if ( $new_price = $lC_Specials->getPrice($Qproducts->valueInt('products_id')) ) { $price = $new_price; } - } + } + + // options modifiers + if (is_array($data['simple_options']) && count($data['simple_options']) > 0) { + $modTotal = 0; + foreach ($data['simple_options'] as $options_id => $values_id) { + $QsimpleOptions = $lC_Database->query("select * from :table_products_simple_options_values where customers_group_id = :customers_group_id and options_id = :options_id and values_id = :values_id and products_id = :products_id limit 1"); + $QsimpleOptions->bindTable(':table_products_simple_options_values', TABLE_PRODUCTS_SIMPLE_OPTIONS_VALUES); + $QsimpleOptions->bindInt(':customers_group_id', '1'); + $QsimpleOptions->bindInt(':products_id', $Qproducts->valueInt('products_id')); + $QsimpleOptions->bindInt(':options_id', $values_id['group_id']); + $QsimpleOptions->bindInt(':values_id', $values_id['value_id']); + $QsimpleOptions->setDebug(true); + $QsimpleOptions->execute(); + + $price = (float)$price + $QsimpleOptions->valueDecimal('price_modifier'); + $QsimpleOptions->freeResult(); + } + } $this->_contents[$Qproducts->valueInt('item_id')] = array('item_id' => $Qproducts->valueInt('item_id'), 'id' => $Qproducts->valueInt('products_id'), diff --git a/catalog/templates/core/content/checkout/checkout_confirmation.php b/catalog/templates/core/content/checkout/checkout_confirmation.php index 14365108d..a9d5d2eda 100644 --- a/catalog/templates/core/content/checkout/checkout_confirmation.php +++ b/catalog/templates/core/content/checkout/checkout_confirmation.php @@ -144,7 +144,8 @@ } if ( $lC_ShoppingCart->hasSimpleOptions($products['item_id']) ) { foreach ( $lC_ShoppingCart->getSimpleOptions($products['item_id']) as $option) { - if ($option['group_title'] != '') echo '
- ' . $option['group_title'] . ': ' . $option['value_title'] . '
' . "\n"; + $mod_price = (($option['price_modifier'] > 0) ? '+' . $option['price_modifier'] : (($option['price_modifier'] == 0) ? null : $option['price_modifier'])); + if ($option['group_title'] != '') echo '
- ' . $option['group_title'] . ': ' . $option['value_title'] . ' ' . $mod_price . '
' . "\n"; } } echo '' . "\n"; diff --git a/catalog/templates/core/content/checkout/checkout_success.php b/catalog/templates/core/content/checkout/checkout_success.php index 29707e54d..c9e6796fa 100644 --- a/catalog/templates/core/content/checkout/checkout_success.php +++ b/catalog/templates/core/content/checkout/checkout_success.php @@ -96,7 +96,8 @@ } if ( is_array($products['options']) && empty($products['options']) === false ) { foreach ( $products['options'] as $key => $option) { - if ($option['group_title'] != '') echo '
- ' . $option['group_title'] . ': ' . $option['value_title'] . '
' . "\n"; + $mod_price = (($option['price_modifier'] > 0) ? '+' . $option['price_modifier'] : (($option['price_modifier'] == 0) ? null : $option['price_modifier'])); + if ($option['group_title'] != '') echo '
- ' . $option['group_title'] . ': ' . $option['value_title'] . ' ' . $mod_price . '
' . "\n"; } } echo '' . "\n";