Results 1 to 10 of 25

Threaded View

  1. #21
    Join Date
    Jul 2012
    Posts
    16,040
    Plugin Contributions
    17

    Default Re: Free Shipping Options (freeoptions) and Rewards

    Quote Originally Posted by mvstudio View Post
    I thought changing the order of the ot_gv might make the code work, but somehow it doesn't. Regardless of where the ot_gv sits, above or below order total nothing changes.

    So I figured my logic isn't quite there.

    I'm thinking there should more considerations for this to run smoothly. Assuming the only 2 variables that lower the order total are coupons or reward points (one or the other never together) then:

    1) Customer's order total is below minimum for FS, no coupons or reward points, therefore cannot checkout with or without GV.
    2) Customer's order total is below minimum for FS including coupons or reward points therefore cannot checkout with or without GV.
    3) Customer's order total is above minimum for FS therefore can checkout with or without GV.

    For scenario 1 the code works BUT if GV present, the checkout process continues, which shouldn't happen.
    For scenario 2 the code works BUT if GV present, the checkout process continues, which shouldn't happen.
    For scenario 3 the code works just fine in the presence of GV or not.


    This is the code I have so far.
    PHP 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)) {

         echo 
    '<div class="buttonRow">' TEXT_CONTINUE_CHECKOUT_PROCEDURE '</div>';
         echo 
    '<div class="buttonRow confirm-order">' zen_image_submit(BUTTON_IMAGE_CONFIRM_ORDERBUTTON_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)) { 
        echo 
    'MESSAGE';  
        
      } else {
    ?> 
    <!-- eof disable checkout button from displaying 1 of 2 -->

    I can't wrap my head around the logic to make it work with the different scenarios. Is it that the cot_gv statement is incorrect and that's why it doesn't work with all the scenarios or that I need more elseif statements to take into account all the combinations?...

    I tried all these combinations and it seems I broke the page. Regardless of what's in the shopping bag it doesn't work.
    PHP Code:
          if (($order->info['total'] < MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN) && (substr_count($_SESSION['shipping']['id'], 'freeoptions') !=0) && ($_SESSION['cot_gv'] !=0)) {
    echo 
    'MESSAGE';

          } elseif ((
    $order->info['total'] = MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN) && (substr_count($_SESSION['shipping']['id'], 'freeoptions') !=0) && ($_SESSION['cot_gv'] !=0)) {
    echo 
    'MESSAGE';

          } elseif ((
    $order->info['total'] > MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN) && (substr_count($_SESSION['shipping']['id'], 'freeoptions') !=0) && ($_SESSION['cot_gv'] !=0)) {
    echo 
    'MESSAGE'
    An "explanation" is provided at the end of each of the if statements about what is going on.
    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 -->
    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...

    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..

    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 -->
    The above should resolve/relate back to what was described earlier than the quoted post with a little bit of a twist:
    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:
    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 "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...

    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...
    Last edited by mc12345678; 27 May 2021 at 12:40 PM.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. Free Shipping Options freeoptions
    By jmberman in forum General Questions
    Replies: 5
    Last Post: 7 Jul 2018, 07:15 PM
  2. Rewards Points Module and rewards by friends (MLM)
    By DArnaez in forum General Questions
    Replies: 1
    Last Post: 15 Dec 2012, 07:25 PM
  3. v138a Force to show free shipping icon w/ freeoptions on
    By prettyodd in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 14 Dec 2012, 12:09 PM
  4. exclude a product or category from Free Shipping freeoptions
    By gotlogos in forum Built-in Shipping and Payment Modules
    Replies: 18
    Last Post: 14 Feb 2012, 01:05 AM
  5. Rewards Points Module and rewards by friends (MLM)
    By minshop.no in forum General Questions
    Replies: 0
    Last Post: 9 Sep 2008, 11:03 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR