Totally Zenned
- Join Date:
- Jul 2006
- Location:
- SF Bay Area
- Posts:
- 837
- Plugin Contributions:
- 1
Applies to FEC and PP Express Checkout - Checkout with insufficient stock
I'm loosing some hair today with sites using either or both PP Express checkout button and FEC module.
Applies to version 1.3.8
Other installed mods: Stock by Attribute 4.7 (not Multi or Ajax)
Symptom: Checkout is allowed with insufficient stock even with proper settings in admin--Stock ie: don't allow checkout.
To fix the PP Express problem: edit ipn_main_handler.php
Near the top, find the line that says:
/**
* handle Express Checkout processing:
*/
if (isset($_GET['type']) && $_GET['type'] == 'ec') {
// this is an EC handler request
require('includes/application_top.php');
and just BELOW that, add the stock check code:
// Stock Check
if ( (STOCK_CHECK == 'true') && (STOCK_ALLOW_CHECKOUT != 'true') ) {
$products = $_SESSION['cart']->get_products();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
if (zen_check_stock($products[$i]['id'], $products[$i]['quantity'])) {
zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
break;
}
}
}
Now for FEC fix...
in includes/modules/pages/no_account/header_php.php find:
// redirect to homepage if no products in cart
if (!$_SESSION['cart']->count_contents() >= 1) {
zen_redirect(zen_href_link(FILENAME_DEFAULT, '', 'NONSSL'));
}
and just BELOW that, add the stock check code:
// Stock Check
if ( (STOCK_CHECK == 'true') && (STOCK_ALLOW_CHECKOUT != 'true') ) {
$products = $_SESSION['cart']->get_products();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
if (zen_check_stock($products[$i]['id'], $products[$i]['quantity'])) {
zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
break;
}
}
}
Now at least in these two places, no more checking out with not enough stock.
Note: These changes work and make sense to me to solve a problem. I looked all over forum for similar fix and see nothing. But then search here isn't so good.
Be careful and happy hacking.
Kiddo