It's not a link - it's a submit button.
Printable View
It's not a link - it's a submit button.
I just installed the plugin and I have items that require attributes to be set.
On some of these items, the price is adjusted based on the attribute selected by just adding to the base price, but in other cases the price is determined by the attribute and the total will be Zero until the attribute is set.
ZenCart normally will not allow you to go any further and not save the item to the cart in this invalid condition without these attributes.
"Save For Later" will go ahead and save these items in its table in a invalid condition. Is there a way to alter the code so "Save For Later" will not save an item, unless the item is in a valid state?
Thanks
You have to prevent the item from being added to your shopping cart in the first place. If it's in the cart, it can be saved for later. But once restored to the cart from save for later, the restrictions you are mentioning would be applied.
Hi Scott,
I've noticed that SFL button from the product page doesn't save the product if an item is out of stock. Is it possible to make it add the item to the Saved for Later list even when stock is 0?
I tested this on a vanilla 1.5.5f install with no other mods installed.
Thanks
You'd have to change the behavior of the shopping cart class to do this.
So SFL is following the ZC core rule that you can't add an out of stock item to the cart?
I tried setting Check Stock Level to false in admin as I thought that would make a difference, but it didn't. In fact, a product still displayed as Sold Out, so not entirely sure of the purpose of that setting!
Would the required changes be within
function actionAddProduct($goto, $parameters) {
of includes/classes/shopping_cart.php ?
Correct.
Ok, I'll look in that function.
It might be an idea for you to update your code to NOT display the SFL button on products where the stock is zero.
I wasn't even aware that it didn't work until someone pointed it out to me.
I saw the button, and assumed it was functional regardless of stock.
I have an issues with this mod.
If you use group pricing, when an item is moved into save for later, it doesn't display the correct price.
As an example, I have a product where products_price is 0.00, and products_group_a_price is 50.54. When the item is in the cart it correctly displays at £50.54, but when moved to SFL, it displays it as £0.00.
So it would seem that sfl_functions isn't aware of what group a logged in user is set to. Given that the sfl_functions file is pretty much a clone of pages/shopping_cart/header.php, I'm surprised this data isn't being passed through.
Is there any chance of a fix for this?
No worries, I looked at the shopping cart class to see how this was being managed, and made some changes to includes/functions/extra_functions/sfl_functions.php to resolve this issue.
The changes are all in function get_sfl_products()
replace the original function with this one
function get_sfl_products() {
global $db;
if($_SESSION['customer_id']) {
$customer_group_query = "SELECT gp.group_name
FROM " . TABLE_CUSTOMERS . " cu
LEFT JOIN " . TABLE_GROUP_PRICING . " gp ON cu.customers_group_pricing=gp.group_id
WHERE cu.customers_id = " . $_SESSION['customer_id'];
if($customer_group = $db->Execute($customer_group_query)) {
$customers_group=$customer_group->fields['group_name'];
}
}
$contents = build_contents();
while (list($products_id, ) = each($contents)) {
$products_query = "select p.products_id, p.master_categories_id, p.products_status, pd.products_name, p.products_model, p.products_image,
p.products_price, p.products_weight, p.products_tax_class_id,
p.products_group_a_price, p.products_group_b_price,
p.products_group_c_price, p.products_group_d_price,
p.products_quantity_order_min, p.products_quantity_order_units,
p.product_is_free, p.products_priced_by_attribute,
p.products_discount_type, p.products_discount_type_from
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_id = '" . (int)$products_id . "'
and pd.products_id = p.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";
if ($products = $db->Execute($products_query)) {
$prid = $products->fields['products_id'];
$products_price = $products->fields['products_price'];
//fix here
/*
$special_price = zen_get_products_special_price($prid);
if ($special_price) {
$products_price = $special_price;
}
*/
$special_price = zen_get_products_special_price($prid);
if ($special_price and $products->fields['products_priced_by_attribute'] == 0) {
$products_price = $special_price;
} else {
$special_price = 0;
}
if($customers_group and $special_price == 0) {
if($customers_group == GROUP_PRICE_PER_ITEM1 && $products->fields['products_group_a_price'] != 0) {
$products_price = $products->fields['products_group_a_price'];
} elseif($customers_group == GROUP_PRICE_PER_ITEM2 && $products->fields['products_group_b_price'] != 0) {
$products_price = $products->fields['products_group_b_price'];
} elseif($customers_group == GROUP_PRICE_PER_ITEM3 && $products->fields['products_group_c_price'] != 0) {
$products_price = $products->fields['products_group_c_price'];
} elseif($customers_group == GROUP_PRICE_PER_ITEM4 && $products->fields['products_group_d_price'] != 0) {
$products_price = $products->fields['products_group_d_price'];
}
}
if (zen_get_products_price_is_free($products->fields['products_id'])) {
// no charge
$products_price = 0;
}
// adjust price for discounts when priced by attribute
if ($products->fields['products_priced_by_attribute'] == '1' and zen_has_product_attributes($products->fields['products_id'], 'false')) {
// reset for priced by attributes
// $products_price = $products->fields['products_price'];
if ($special_price) {
$products_price = $special_price;
} else {
$products_price = $products->fields['products_price'];
}
} else {
// discount qty pricing
if ($products->fields['products_discount_type'] != '0') {
$products_price = zen_get_products_discount_price_qty($products->fields['products_id'], $contents[$products_id]['qty']);
}
}
//clr 030714 update $products_array to include attribute value_text. This is needed for text attributes.
// convert quantity to proper decimals
if (QUANTITY_DECIMALS != 0) {
// $new_qty = round($new_qty, QUANTITY_DECIMALS);
$fix_qty = $contents[$products_id]['qty'];
switch (true) {
case (!strstr($fix_qty, '.')):
$new_qty = $fix_qty;
break;
default:
$new_qty = preg_replace('/[0]+$/','',$contents[$products_id]['qty']);
break;
}
} else {
$new_qty = $contents[$products_id]['qty'];
}
$check_unit_decimals = zen_get_products_quantity_order_units((int)$products->fields['products_id']);
if (strstr($check_unit_decimals, '.')) {
$new_qty = round($new_qty, QUANTITY_DECIMALS);
} else {
$new_qty = round($new_qty, 0);
}
if ($new_qty == (int)$new_qty) {
$new_qty = (int)$new_qty;
}
$products_array[] = array('id' => $products_id,
'category' => $products->fields['master_categories_id'],
'name' => $products->fields['products_name'],
'model' => $products->fields['products_model'],
'image' => $products->fields['products_image'],
'price' => ($products->fields['product_is_free'] =='1' ? 0 : $products_price),
// 'quantity' => $contents[$products_id]['qty'],
'quantity' => $new_qty,
// 'weight' => $products->fields['products_weight'] + $attributes_weight($products_id),
// fix here
'final_price' => ($products_price + attributes_price($products_id, $contents)),
'onetime_charges' => (attributes_price_onetime_charges($products_id, $new_qty, $contents)),
'tax_class_id' => $products->fields['products_tax_class_id'],
'attributes' => (isset($contents[$products_id]['attributes']) ? $contents[$products_id]['attributes'] : ''),
'attributes_values' => (isset($contents[$products_id]['attributes_values']) ? $contents[$products_id]['attributes_values'] : ''),
'products_priced_by_attribute' => $products->fields['products_priced_by_attribute'],
'product_is_free' => $products->fields['product_is_free'],
'products_discount_type' => $products->fields['products_discount_type'],
'products_discount_type_from' => $products->fields['products_discount_type_from']);
}
}
return $products_array;
}