Hi All,
Great add-on.
Dual Pricing not showing correct wholesale price for products priced by attribute
I am running ZC 1.5.4 + Qty discount 1,1,2 and dual pricing 2.1.5 from github - Normal items ie not priced by attributes are working great.
1) no trade field in attributes editor ( search all files in all versions of plugin and field is definitely called wholesale) - no biggie
2) All levels of wholesale pricing are running for not attribute priced product. (i have 5)
3) If i put in 5 levels of attribute wholesale pricing in wholesale field (xx.00,yy.00,zz.00...
4) Non wholesale user gets right price
5) Level 1 user gets 2 prices in product info page as it should list and wholesale and in pull down for attributes gets list proce and xx.00 - All OK
6) level 1 then adds to cart and xx.00 is added to cart - All OK
Now Level 2 user
1) Product page shows whole sale (Retail/ wholesale) and retail All ok..
2) Add to cart - cart shows xx.00 ie the first wholesale in the list xx,yy,zz - WRONG...
The code i believe in the plug-in for /included/classes/shopping_cart is the is the problem.
There are multiple instances of the below code and I believe it is the fault:
Code:
ifif ($_SESSION['customer_id']) {
$customers_id = $_SESSION['customer_id'];
$customer_check = $db->Execute("select * from " . TABLE_CUSTOMERS . " where customers_id = '$customers_id'");
if ($customer_check->fields['customers_whole'] != "0") {
$i = $customer_check->fields['customers_whole'];
$i--;
$options_value_price = (float)$attribute_price->fields['options_values_price_w'];
The value
Code:
$options_value_price = (float)$attribute_price->fields['options_values_price_w'];
Is all wrong as
Code:
$attribute_price->fields['options_values_price_w'
contains the attributes wholesale field ie xx.00,yy.00 as a string and floating it just screws it up and returns the first float value xx.00
So how to do it?
I have tried
Code:
if ($_SESSION['customer_id']) {
$customers_id = $_SESSION['customer_id'];
$customer_check = $db->Execute("select * from " . TABLE_CUSTOMERS . " where customers_id = '$customers_id'");
if ($customer_check->fields['customers_whole'] != "0") {
$i = (int)$customer_check->fields['customers_whole']; //Grab the Wholesale level as integer
$i--; //Decrement it as arrays start with [0]
// $options_value_price = (float)$attribute_price->fields['options_values_price_w']; // Comment out the old line
$brm_options_array = explode(",",$attribute_price->fields['options_values_price_w']); //explode the xx.00,yy.00,zz.00 string into an array
$options_value_price = (float)$brm_options_array[$i]; // pull the appropriate discount price for the wholesale level out - var_dump($options_value_price ) returns the correct attribute wholesale level
Problem is - it is still not working.
As I mentioned in shopping_cart.php there are about 3 instances of this code and I have tried all 3 - Just don't get how this works.
Or more importantly passes it to the html.
Any assistance would be appreciated.
Thanks in advance
Bookmarks