sv1eez Posted March 6, 2005 Share Posted March 6, 2005 Hi all, thanks to the creators of SPPC for a great contribution. I installed SPPC and after two days of fighting with my other installed contributions it seems to work well with all of them except one, the Bundled Products contribution. In this contribution, on the product_info.php page there is a reference about the total cost of the bundled products when purchased separately and the total amount of money the customer pays less if they are bought as a bundle. The problem is that althought I have entered prices for the bundled products for my "wholesale" group of customers the amount of the total bundle cost and the money the customer pays less when bying a bundle are those derived from the retail customer group pricing. I know where to look to fix this but my php knoeledge is not that good. If anyone could help I would be grateful. Here is the part of my product_info.php which produces the total cost and the bundle gain amounts. <!-- start bundle --> <?php if ($product_info['products_bundle'] == "yes") { $products_bundle = $product_info['products_bundle']; echo TEXT_BUNDLE_CONTENTS . "<br><table>"; $bundle_query = tep_db_query(" SELECT pd.products_name, pb.*, p.products_bundle, p.products_id, p.products_price FROM products p INNER JOIN products_description pd ON p.products_id=pd.products_id INNER JOIN products_bundles pb ON pb.subproduct_id=pd.products_id WHERE pb.bundle_id = " . tep_get_prid($products_id) . " and language_id = '" . (int)$languages_id . "'"); while ($bundle_data = tep_db_fetch_array($bundle_query)) { if ($bundle_data['products_bundle'] == "yes") { // uncomment the following line to display subproduct qty //echo "<br>» <b>" . $bundle_data['subproduct_qty'] . " x " . $bundle_data['products_name'] . "</b>"; //echo "<br>» <b> " . $bundle_data['products_name'] . "</b>"; echo '<tr><td valign="top" class="main">» <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $bundle_data['products_id']) . '"><b><u>' . $bundle_data['products_name'] . '</u></b></a></td></tr>'; $bundle_query_nested = tep_db_query(" SELECT pd.products_name, pb.*, p.products_bundle, p.products_id, p.products_price FROM products p INNER JOIN products_description pd ON p.products_id=pd.products_id INNER JOIN products_bundles pb ON pb.subproduct_id=pd.products_id WHERE pb.bundle_id = " . $bundle_data['products_id'] . " and language_id = '" . (int)$languages_id . "'"); while ($bundle_data_nested = tep_db_fetch_array($bundle_query_nested)) { // uncomment the following line to display subproduct qty //echo "<br><i> " . $bundle_data_nested['subproduct_qty'] . " x " . $bundle_data_nested['products_name'] . "</i>"; //echo "<br><i> " . $bundle_data_nested['products_name'] . "</i>"; echo '<tr><td valign="top" class="main"> <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $bundle_data_nested['products_id']) . '"><i><u>' . $bundle_data_nested['products_name'] . '</u></i></a></td></tr>'; // CB use special price if available if ($new_price = tep_get_products_special_price($bundle_data_nested['products_id'])) { $bundle_sum += $new_price*$bundle_data_nested['subproduct_qty']; } else { $bundle_sum += $bundle_data_nested['products_price']*$bundle_data_nested['subproduct_qty']; } // endof CB mod } } else { // uncomment the following line to display subproduct qty // echo "<br>» <b>" . $bundle_data['subproduct_qty'] . " x " . $bundle_data['products_name'] . "</b>"; //echo "<br>» <b> " . $bundle_data['products_name'] . "</b>"; echo '<tr><td valign="top" class="main">» <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $bundle_data['products_id']) . '"><b><u>' . $bundle_data['products_name'] . '</u></b></a></td></tr>'; // CB use special price if available if ($new_price = tep_get_products_special_price($bundle_data_nested['products_id'])) { $bundle_sum += $new_price*$bundle_data['subproduct_qty']; } else { $bundle_sum += $bundle_data['products_price']*$bundle_data['subproduct_qty']; } // endof CB mod } } // CB use special bundle price if available if ($new_price = tep_get_products_special_price($product_info['products_id'])) { $bundle_saving = $bundle_sum - $new_price; } else { $bundle_saving = $bundle_sum - $product_info['products_price']; } // endof CB mod $bundle_sum = $currencies->display_price($bundle_sum, tep_get_tax_rate($product_info['products_tax_class_id'])); $bundle_saving = $currencies->display_price($bundle_saving, tep_get_tax_rate($product_info['products_tax_class_id'])); // comment out the following line to hide the "saving" text echo '</table><p><table><tr><td class="main" align="right">' . TEXT_BUNDLE_SUM . '</td><td class="main"><span class="productPrice">' . $bundle_sum . '</span></td></tr><tr><td class="main" align="right">' . TEXT_BUNDLE_SAVINGS . '</td><td class="main"><span class="productSpecialPrice">' . $bundle_saving . '</span></td></tr></table>'; } ?> <!-- end bundle --> Thank you in advance. Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted March 8, 2005 Share Posted March 8, 2005 It is a bit tricky perhaps, because you rely on a "derived" table of prices, but I think it is the simplest solution (hopefully a solution anyway) by using the dynamically generated table with the products price and specials price for the customer group (normally only used for sorting on price in index.php and advanced_search_results.php when a search is done on a price range): <?php // BOF Separate Pricing Per Customer if(!tep_session_is_registered('sppc_customer_group_id')) { $customer_group_id = '0'; } else { $customer_group_id = $sppc_customer_group_id; } // EOF Separate Pricing Per Customer if ($product_info['products_bundle'] == "yes") { $products_bundle = $product_info['products_bundle']; echo TEXT_BUNDLE_CONTENTS . "<br><table>"; if ($customer_group_id != '0') { $bundle_query = tep_db_query(" SELECT pd.products_name, pb.*, p.products_bundle, p.products_id, pgp.products_price FROM products p LEFT JOIN products_group_prices_cg_".(int)$customer_group_id." pgp using(products_id) INNER JOIN products_description pd ON p.products_id=pd.products_id INNER JOIN products_bundles pb ON pb.subproduct_id=pd.products_id WHERE pb.bundle_id = " . tep_get_prid($products_id) . " and language_id = '" . (int)$languages_id . "'"); } else { $bundle_query = tep_db_query(" SELECT pd.products_name, pb.*, p.products_bundle, p.products_id, p.products_price FROM products p INNER JOIN products_description pd ON p.products_id=pd.products_id INNER JOIN products_bundles pb ON pb.subproduct_id=pd.products_id WHERE pb.bundle_id = " . tep_get_prid($products_id) . " and language_id = '" . (int)$languages_id . "'"); } while ($bundle_data = tep_db_fetch_array($bundle_query)) { etc. etc. Perhaps if this works it would be good to include the check on the status of that table: tep_db_check_age_products_group_prices_cg_table($customer_group_id); Quote Link to comment Share on other sites More sharing options...
blanktape Posted September 26, 2006 Share Posted September 26, 2006 It is a bit tricky perhaps, because you rely on a "derived" table of prices, but I think it is the simplest solution (hopefully a solution anyway) by using the dynamically generated table with the products price and specials price for the customer group (normally only used for sorting on price in index.php and advanced_search_results.php when a search is done on a price range): <?php // BOF Separate Pricing Per Customer if(!tep_session_is_registered('sppc_customer_group_id')) { $customer_group_id = '0'; } else { $customer_group_id = $sppc_customer_group_id; } // EOF Separate Pricing Per Customer if ($product_info['products_bundle'] == "yes") { $products_bundle = $product_info['products_bundle']; echo TEXT_BUNDLE_CONTENTS . "<br><table>"; if ($customer_group_id != '0') { $bundle_query = tep_db_query(" SELECT pd.products_name, pb.*, p.products_bundle, p.products_id, pgp.products_price FROM products p LEFT JOIN products_group_prices_cg_".(int)$customer_group_id." pgp using(products_id) INNER JOIN products_description pd ON p.products_id=pd.products_id INNER JOIN products_bundles pb ON pb.subproduct_id=pd.products_id WHERE pb.bundle_id = " . tep_get_prid($products_id) . " and language_id = '" . (int)$languages_id . "'"); } else { $bundle_query = tep_db_query(" SELECT pd.products_name, pb.*, p.products_bundle, p.products_id, p.products_price FROM products p INNER JOIN products_description pd ON p.products_id=pd.products_id INNER JOIN products_bundles pb ON pb.subproduct_id=pd.products_id WHERE pb.bundle_id = " . tep_get_prid($products_id) . " and language_id = '" . (int)$languages_id . "'"); } while ($bundle_data = tep_db_fetch_array($bundle_query)) { etc. etc. Perhaps if this works it would be good to include the check on the status of that table: tep_db_check_age_products_group_prices_cg_table($customer_group_id); >_< Sorry to dig this out from the grave, but hopefully someone will read it and help us here. I tried the code but still doesnt work.... if anyone has better solution please help here.. hard to find products that can bundled together but also work for sppc. by the way i am using sppc 4.1 thanks in advance.... Quote Link to comment Share on other sites More sharing options...
beeman147 Posted April 7, 2009 Share Posted April 7, 2009 I am also trying to do this, with my severely limited php knowledge... if i get it working then i will post my product_info page code here... Does anybody know if this tricky one has been solved elsewhere? Would be great to find, as both these contribs are superb in their own right. bee :-) Quote There are 10 types of people in this world, those who understand binary and those who don't... Link to comment Share on other sites More sharing options...
Jan Zonjee Posted April 7, 2009 Share Posted April 7, 2009 Does anybody know if this tricky one has been solved elsewhere? How does this change work: // CB use special price if available if ($new_price = tep_get_products_special_price($bundle_data_nested['products_id'])) { $bundle_sum += $new_price*$bundle_data_nested['subproduct_qty']; } else { $bundle_data_nested['products_price'] = getSppcPrice($bundle_data_nested['products_id'], $bundle_data_nested['products_price']); $bundle_sum += $bundle_data_nested['products_price']*$bundle_data_nested['subproduct_qty']; } // endof CB mod } } else { // uncomment the following line to display subproduct qty // echo "<br>» <b>" . $bundle_data['subproduct_qty'] . " x " . $bundle_data['products_name'] . "</b>"; //echo "<br>» <b> " . $bundle_data['products_name'] . "</b>"; echo '<tr><td valign="top" class="main">» <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $bundle_data['products_id']) . '"><b><u>' . $bundle_data['products_name'] . '</u></b></a></td></tr>'; // CB use special price if available if ($new_price = tep_get_products_special_price($bundle_data_nested['products_id'])) { $bundle_sum += $new_price*$bundle_data['subproduct_qty']; } else { $bundle_data['products_price'] = getSppcPrice($bundle_data['products_id'], $bundle_data['products_price']); $bundle_sum += $bundle_data['products_price']*$bundle_data['subproduct_qty']; } // endof CB mod } } // CB use special bundle price if available if ($new_price = tep_get_products_special_price($product_info['products_id'])) { $bundle_saving = $bundle_sum - $new_price; } else { // assuming that $product_info['products_price'] has already been set to customer group price $bundle_saving = $bundle_sum - $product_info['products_price']; } // endof CB mod You would need to add this function to includes/functions/general.php: function getSppcPrice ($products_id, $products_price = 0) { $cust_group_price = ''; if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') { $customer_group_id = $_SESSION['sppc_customer_group_id']; } else { $customer_group_id = '0'; } if ($customer_group_id == '0') { return $products_price; // customer is retail: price is retail price } $customer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$products_id . "' and customers_group_id = '" . $customer_group_id . "'"); if ($customer_group_price = tep_db_fetch_array($customer_group_price_query)) { $cust_group_price = $customer_group_price['customers_group_price']; return $cust_group_price; } else { return $products_price; // price stays retail price since there is no customer group price } } Quote Link to comment Share on other sites More sharing options...
beeman147 Posted April 20, 2009 Share Posted April 20, 2009 Thanks Jan The last solution with the Sppc function works perfectly. Bee Quote There are 10 types of people in this world, those who understand binary and those who don't... Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.