Yes, it's going to get a little complicated, but if it helps others, that's all it matters.
I'll post the final once I know it works.
Thanks for the help! =o)
Yes, it's going to get a little complicated, but if it helps others, that's all it matters.
I'll post the final once I know it works.
Thanks for the help! =o)
Assuming you have constants for freeoptions and its clones like
MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN
MODULE_SHIPPING_FREEOPTIONS2_TOTAL_MIN
MODULE_SHIPPING_FREEOPTIONS3_TOTAL_MIN
you could do something likePHP Code:
<?php
$free_ship_on = MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING;
if ($free_ship_on == 'false') {
echo '<div id="cartFreeShip">';
$free_limit = MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN; //mi
$free_limit2 = MODULE_SHIPPING_FREEOPTIONS2_TOTAL_MIN; //cont
$free_limit3 = MODULE_SHIPPING_FREEOPTIONS3_TOTAL_MIN; //canada
$diff_to_free = ($free_limit - $cart_total);
$diff_to_free2 = ($free_limit2 - $cart_total);
$diff_to_free3 = ($free_limit3 - $cart_total);
//if ($cart_count) { //hopefully this is not needed in order to evaluate $_SESSION['cart']->show_total() which can == 0 for this code
// $_SESSION['cart']->get_products(); //this was leftover from old code and has no current function in any case, so just delete it
$cart_total = $_SESSION['cart']->show_total();
if ($cart_total >= $free_limit3) {
echo CART_HEADER_QUALIFIES;
} elseif ($cart_total >= $free_limit2) {
echo CART_HEADER_QUALIFIES_MI_CONT . $currencies->format($diff_to_free3) . CART_HEADER_DIFF_POST_CANADA;
} elseif ($cart_total >= $free_limit) {
echo CART_HEADER_QUALIFIES_MI . $currencies->format($diff_to_free2) . CART_HEADER_DIFF_POST_CONT . $currencies->format($diff_to_free3) . CART_HEADER_DIFF_POST_CANADA;
} else {
echo CART_HEADER_DIFF_PRE . $currencies->format($diff_to_free) . CART_HEADER_DIFF_POST . CART_HEADER_DIFF_PRE_CONT . $currencies->format($diff_to_free2) . CART_HEADER_DIFF_POST_CONT . CART_HEADER_DIFF_PRE_CANADA . $currencies->format($diff_to_free3) . CART_HEADER_DIFF_POST_CANADA;
}
//} else { //doesn't work for 3 zones
// echo CART_HEADER_FREE_LIMIT_PRE . $currencies->format($free_limit) . CART_HEADER_FREE_LIMIT_POST;
//} //if need to use $cart_count, expand the above like the previous else case substituting $free_limit/2/3 for $diff_to_free/2/3
echo '</div>';
} ?>
You're a genius!!!
Thank you!! It works perfectly!
Good to hear that. So the commented-out if() is not needed, I take it?
Correct. Not needed. It actually breaks the page.
In the spirit of sharing, I made some other changes that work for my case. I wanted so display Free Shipping Over $XXX when shopping cart is 0 instead of the whole message "add $xx for free shipping etc."
So I added a conditional if the cart is 0 which triggers a different message
The define CART_HEADER can be any shorter message. In my case it just displays "Free Continental Shipping over $85"PHP Code:
<?php
$free_ship_on = MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING;
if ($free_ship_on == 'false') {
echo '<div id="cartFreeShip">';
$free_limit = MODULE_SHIPPING_FREEOPTIONS_MICHIGAN_TOTAL_MIN; //mi
$free_limit2 = MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN; //continental us
$free_limit3 = MODULE_SHIPPING_FREEOPTIONSINT_TOTAL_MIN; //canada
$diff_to_free = ($free_limit - $cart_total);
$diff_to_free2 = ($free_limit2 - $cart_total);
$diff_to_free3 = ($free_limit3 - $cart_total);
//if ($cart_count) { //hopefully this is not needed in order to evaluate $_SESSION['cart']->show_total() which can == 0 for this code
// $_SESSION['cart']->get_products(); //this was leftover from old code and has no current function in any case, so just delete it
$cart_total = $_SESSION['cart']->show_total();
if ($cart_total >= $free_limit3) {
echo CART_HEADER_QUALIFIES_CANADA;
} elseif ($cart_total >= $free_limit2) {
echo CART_HEADER_QUALIFIES_CONT . CART_HEADER_DIFF_PRE . $currencies->format($diff_to_free3) . CART_HEADER_DIFF_POST_CANADA;
} elseif ($cart_total >= $free_limit) {
echo CART_HEADER_QUALIFIES . CART_HEADER_DIFF_PRE . $currencies->format($diff_to_free2) . CART_HEADER_DIFF_POST_CONT . $currencies->format($diff_to_free3) . CART_HEADER_DIFF_POST_CANADA;
} elseif ($cart_total == '0') {
echo CART_HEADER;
} else {
echo CART_HEADER_DIFF_PRE . $currencies->format($diff_to_free) . CART_HEADER_DIFF_POST . CART_HEADER_DIFF_PRE_CONT . $currencies->format($diff_to_free2) . CART_HEADER_DIFF_POST_CONT . CART_HEADER_DIFF_PRE_CANADA . $currencies->format($diff_to_free3) . CART_HEADER_DIFF_POST_CANADA; }
//} else { //doesn't work for 3 zones
// echo CART_HEADER_FREE_LIMIT_PRE . $currencies->format($free_limit) . CART_HEADER_FREE_LIMIT_POST;
//} //if need to use $cart_count, expand the above like the previous else case substituting $free_limit/2/3 for $diff_to_free/2/3
echo '</div>';
} ?>
Hello everyone,
Has anyone suggestions on how to exclude certain category id's and product id's from being calculated in the free shipping header?
// bof This is to remove Category from free shipping always
if (!IS_ADMIN_FLAG) {
global $cart;
$chk_cat = 0;
$chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id', '9');
$chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id', '21');
if ($chk_cat > 0) {
$this->enabled = false;
}
}
// eof This is to remove Category from free shipping always
The above code works in freeoptions.php but not in the freeship header.
Thanks
That code appears to be part of a class file, and will not work as is outside of the class.
$this->enabled = false;
is not applicable or meaningful in the shoppingcart/freeship files. You would have to rework the action based on the test and the new file context.
I'd like to hide the header cart unless there is something in the cart. Any ideas on the code for that? Thank you in advance. Limey
That is pretty easy. Find this at the top of tpl_cart_header.php:and change toPHP Code:
$cart_count = $_SESSION['cart']->count_contents();
?>
<div id="cartHeader">
At the bottom of the file, find this:PHP Code:
$cart_count = $_SESSION['cart']->count_contents();
if ($cart_count) { //only show if something in cart
?>
<div id="cartHeader">
and change toPHP Code:
} ?>
</div>
If you want the wrapper div to remain as a placeholder for the layout, move the test inside the div, like thisPHP Code:
} ?>
</div>
<?php } // /only show
?>PHP Code:
$cart_count = $_SESSION['cart']->count_contents();
?>
<div id="cartHeader">
<?php if ($cart_count) { //only show if something in cart
?>
//body of file
}
} // /only show
?>
</div>
Thanks Glenn - that works a treat. Appreciate appreciate.
Limey
Bookmarks