Page 3 of 3 FirstFirst 123
Results 21 to 25 of 25
  1. #21
    Join Date
    Jul 2012
    Posts
    16,710
    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...

  2. #22
    Join Date
    Jul 2012
    Posts
    16,710
    Plugin Contributions
    17

    Default Re: Free Shipping Options (freeoptions) and Rewards

    Hey and self profession here, I am under the current assumption (based on the reported operation of the first set of code posted in the above code) that $_SESSION['cot_gv'] represents an amount of a gift certificate and not associated with a coupon or rewards points... If that assumption is wrong, then the technical aspect of the above code is to be different so as to match the actual variables that are present to represent the condition. I likely didn't need to make this statement, but the last couple of posts have been a little confusing between the desire, expectation and code... I claim that to be on my side because I haven't gone through the code (in a few days) to identify how $_SESSION['cot_gv'] is generated/used... That's bad on me, but I've been meaning to try to provide the above reworked code for you.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #23
    Join Date
    Apr 2008
    Posts
    446
    Plugin Contributions
    1

    Default Re: Free Shipping Options (freeoptions) and Rewards

    Thank you for taking the time in helping me out!! And sorry for the late reply! My son is graduating high school and time seems to be on the short side these days. My php is so limited I wouldn't have thought of that approach. However things still don't work with either of those codes, hopefully I can explain why.

    Quote Originally Posted by mc12345678 View Post
    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 actual issue with the original code I wrote (, was that GVs couldn't be used at all to pay for the order. Because GVs lower the order total the original code triggered the message the order no longer qualifies for free shipping. So I needed to be able for customers paying with GV to checkout if certain conditions were met. The main issue was when free shipping was selected and if the order had coupons or reward points. If order has free shipping selected and order total met minimum for free shipping to be granted then checkout. If order has free shipping selected, and coupons lowering the order total below the minimum for free shipping were present, then do not checkout.


    Let me show you what the original issue was with the original code I started with, hopefully you can visualize my predicament.
    The original code I started with...
    PHP Code:
    <!-- bof disable checkout button from displaying  -->
    <?php
    if (!IS_ADMIN_FLAG) { 
        global 
    $order$db;
          if ((
    $order->info['total'] < MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN) && (substr_count($_SESSION['shipping']['id'], 'freeoptions') !=0)) { 
      
        echo 
    'MESSAGE ORDER NO LONGER QUALIFIES FOR FREE SHIPPING';  
      } else {
    ?>
    <!-- eof disable checkout button from displaying  -->
    I offer free shipping on orders totaling $99.99 or more.
    With the above code I ran into these problems.

    Scenario 1
    Order total: $100
    Free shipping: $0.00
    Reward points: $0.00
    Coupons: $0.00
    Customer pays with CC or PayPal can checkout as order meets minimum of $99.99.
    Customer paying with GV cannot checkout. <- this shouldn't have happened.

    Scenario 2
    Order total: $100
    Free shipping: $0.00
    Reward points: $0.00
    Coupons: -$5.00
    New Order total: $95.00
    Customer pays with CC or PayPal cannot checkout as order doesn't meet minimum of $99.99.
    Customer paying with GV cannot checkout. <- this is great, it shouldn't checkout, but this was a fluke.

    Scenario 3
    Order total: $100
    Shipping: $12.00
    Reward points: $0.00
    Coupons: -$5.00
    New Order total: $107.00
    Customer pays with CC or PayPal can checkout.
    Customer paying with GV cannot checkout. <- this shouldn't have happened.


    I came to the conclusion because GV lowered the order total the code detected that the order total was below the minimum threshold for free shipping therefore no checkout. So with your help, the code morphed into this one below:
    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 ORDER NO LONGER QUALIFIES FOR FREE SHIPPING';   
        
      } else {
    ?> 
    <!-- eof disable checkout button from displaying 1 of 2 -->
    Running similar scenarios:

    Scenario 1
    Order total: $100
    Free shipping: $0.00
    Reward points: $0.00
    Coupons: $0.00
    Customer pays with CC or PayPal can checkout as order meets minimum of $99.99.
    Customer paying with GV can now checkout. <- this is great!

    Scenario 2
    Order total: $100
    Free shipping: $0.00
    Reward points: $0.00
    Coupons: -$5.00
    New Order total: $95.00
    Customer pays with CC or PayPal cannot checkout as order doesn't meet minimum of $99.99.
    Customer paying with GV can checkout <- this shouldn't happen as order doesn't meet minimum of $99.99 for free shipping.

    Scenario 3
    Order total: $100
    Shipping: $12.00
    Reward points: $0.00
    Coupons: -$5.00
    New Order total: $107.00
    Customer pays with CC or PayPal can checkout.
    Customer paying with GV can checkout. <- this is great!

    With your latest two codes and running the same scenarios as above, the same thing happens. If the order falls below the minimum for free shipping to be granted, customers paying with GV can still checkout when they shouldn't.

    I hope this helps in visualizing my conundrum.

    Hey and self profession here, I am under the current assumption (based on the reported operation of the first set of code posted in the above code) that $_SESSION['cot_gv'] represents an amount of a gift certificate and not associated with a coupon or rewards points... If that assumption is wrong, then the technical aspect of the above code is to be different so as to match the actual variables that are present to represent the condition. I likely didn't need to make this statement, but the last couple of posts have been a little confusing between the desire, expectation and code... I claim that to be on my side because I haven't gone through the code (in a few days) to identify how $_SESSION['cot_gv'] is generated/used... That's bad on me, but I've been meaning to try to provide the above reworked code for you.
    That's correct $_SESSION['cot_gv'] represents an amount of a gift certificate to pay for the order either in its totality or partiality, and nothing to do with coupons or reward points. Should I have not used that?

    Sorry if I haven't explained the issue correctly. I'm having problems visualizing the problem completely and my very minimum understanding of php is of no help. For that I apologize if I made things worse.

  4. #24
    Join Date
    Apr 2008
    Posts
    446
    Plugin Contributions
    1

    Default Re: Free Shipping Options (freeoptions) and Rewards

    I'm wondering if perhaps this whole thing could be solved by adding a duplicate of the ot_total module or perhaps a code that would provide a calculation of the complete order total and if above the free shipping then checkout and if below the free shipping then do not checkout?... Could this be an approachable solution if this becomes a nightmare to figure out?...

  5. #25
    Join Date
    Apr 2008
    Posts
    446
    Plugin Contributions
    1

    Default Re: Free Shipping Options (freeoptions) and Rewards

    Quote Originally Posted by mc12345678 View Post
    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) && !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 -->
    So I went with my "gut" which lately doesn't amount to much, and made a duplicate of the ot_total module which I called ot_total_final. I gave that module a sort order right above ot_gv and I placed ot_total right below ot_gv as shown in the picture.

    Name:  temporary.jpg
Views: 167
Size:  92.9 KB

    Somehow or so it seems, this duplicate ot_total module sort of did the trick, I don't know if it even makes any sense, and now the code above which you provided works. I ran many scenarios and if the order total lands below the minimum for free shipping, the message to change shipping or add more products displays with and without GV. If the order total lands above the minimum for free shipping then the checkout can proceed with or without GV as it should.

    In your experience, does this makes any sense at all?... The code above wouldn't work with just one ot_total module, but it works with 2??... Have I messed things up exponentially??...

 

 
Page 3 of 3 FirstFirst 123

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