An "explanation" is provided at the end of each of the if statements about what is going on.
Now, I thought that earlier discussion was that the GV was considered "real money" and therefore, if the order total is reduced by the GV to be below the minimum, then it should be acceptable BUT only if the total is reduced below the minimum specifically because of the amount of the GV not just because it was used...Code:<!-- bof disable checkout button from displaying 1 of 2 --> <?php if (!IS_ADMIN_FLAG) { global $order, $db; if (($order->info['total'] < MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN) && (substr_count($_SESSION['shipping']['id'], 'freeoptions') !=0) && ($_SESSION['cot_gv'] !=0)) { // Do the following (show button) if below the min, free options is offered and a gift certificate is used. echo '<div class="buttonRow">' . TEXT_CONTINUE_CHECKOUT_PROCEDURE . '</div>'; echo '<div class="buttonRow confirm-order">' . zen_image_submit(BUTTON_IMAGE_CONFIRM_ORDER, BUTTON_CONTINUE_CHECKOUT_CONFIRMATION_ALT, 'name="btn_submit" id="btn_submit"') . '</div>'; } elseif (($order->info['total'] < MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN) && (substr_count($_SESSION['shipping']['id'], 'freeoptions') !=0)) { // Stop checkout if below the minimum and free options is displayed echo 'MESSAGE'; } else { // standard checkout, basically total is anything that doesn't cause freeoptions to display. ?> <!-- eof disable checkout button from displaying 1 of 2 -->
The current #1 analysis says its ok to checkout if the total is anywhere below the minimum for free shipping, just as long as a gift certificate was used... What really should be done in this situation is to evaluate the order total as compared against the amount of the gift certificate to determine if the low total is caused by the gift certificate... E.g. $order->info['total'] + $_SESSION['ot_gv'] < MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN then stop the purchase, but if it is >= to that then allow it... so..
The above should resolve/relate back to what was described earlier than the quoted post with a little bit of a twist:Code:<!-- bof disable checkout button from displaying 1 of 2 --> <?php if (!IS_ADMIN_FLAG) { global $order, $db; if (($order->info['total'] < MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN) && (substr_count($_SESSION['shipping']['id'], 'freeoptions') !=0) && !empty($_SESSION['cot_gv']) && (($_SESSION['cot_gv'] + $order->info['total']) >= MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN)) { // Do the following (show button) if total is below the min, free options is offered, a gift certificate is used and the sum of the gift certificate and order total is equal to or greater than the minimum. ?><div class="buttonRow"><?php echo TEXT_CONTINUE_CHECKOUT_PROCEDURE; ?></div> <div class="buttonRow confirm-order"><?php echo zen_image_submit(BUTTON_IMAGE_CONFIRM_ORDER, BUTTON_CONTINUE_CHECKOUT_CONFIRMATION_ALT, 'name="btn_submit" id="btn_submit"'); ?></div> <?php } elseif (($order->info['total'] < MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN) && (substr_count($_SESSION['shipping']['id'], 'freeoptions') !=0)) { // Stop checkout if below the minimum and free options is displayed (Note that at this point of execution, the gift certificate is not a factor because if it "helped" then this code is not reached). echo 'MESSAGE'; } else { // standard checkout, basically total is anything that doesn't cause freeoptions to display. ?> <!-- eof disable checkout button from displaying 1 of 2 -->
1) Customer's order total is below minimum for FS, no coupons or reward points, GV used that increases sum of total and GV to >= min for FS: therefore can checkout.
2) Customer's order total is below minimum for FS including coupons or reward points, GV used that increases sum of total and GV to >= min for FS: therefore can checkout.
3) Customer's order total is below minimum for FS, no coupons or reward points, GV used that causes sum of total and GV to be < min for FS: cannot checkout
4) Customer's order total is below minimum for FS including coupons or reward points, GV used that causes sum of total and GV to be < min for FS: cannot checkout.
5) Customer's order total is below minimum for FS, no coupons or rewards points, no GV used: cannot checkout.
6) Customer's order total is below minimum for FS, including coupons or rewards points, GV not used: cannot checkout.
7) Customer's order total is equal to or above minimum for FS therefore can checkout with/without coupons or rewards points and with/without GV.
So, all of the above, which likely could create more scenarios as 7 covers several conditions is to use more of a logic process, unrelated to php or code to narrow down the requirements and to then consider them in a sequence (supports an if/elseif/else structure) or could use variable assignment and run through each test individually, etc... but best to keep doing what is being done above in testing a condition that if untrue will allow testing a less restrictive condition.
Considering the description of what was happening as compared to what was provided in the code, if the total is above the minimum or the use of a gift certificate is the cause of the total going below the minimum and a gift certificate is to be treated as "hard cash" then one should be permitted to checkout regardless the use of any other price reducing feature, otherwise if the total is below the minimum stop the process.
FYI, based on what I just wrote, the above code can be simplified even more to offer the "unique" situation of blocking checkout only in a specific condition:
This "summarizes" what I wrote to where shopping is stopped if: the total is low, freeoptions is offered and either there is no GV or there is but the amount of the GV plus the total is still less than the minimum...Code:<!-- bof disable checkout button from displaying 1 of 2 --> <?php if (!IS_ADMIN_FLAG) { // NOTE: THIS NEEDS TO BE CLOSED SOMEWHERE which I don't see here... global $order, $db; if (($order->info['total'] < MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN) && (substr_count($_SESSION['shipping']['id'], 'freeoptions') !=0) && (empty($_SESSION['cot_gv']) || (($_SESSION['cot_gv'] + $order->info['total']) < MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN))) { // Stop checkout if below the minimum and free options is displayed and gift certificate amount is insufficient to exceed the minimum. echo 'MESSAGE'; } else { // standard checkout, basically total is anything that doesn't cause freeoptions to display. ?> <!-- eof disable checkout button from displaying 1 of 2 -->
This one is a little better for coding if there is no need to provide a specific/different message for those using a gift certificate that caused the amount of money used to exceed the minimum...
Bookmarks