If this is your first visit, check our documentation. To post, register or login.
Forums / Community Contributed Add-Ons / Addon Shipping Modules / Free Shipping Options (freeoptions) and Rewards

Free Shipping Options (freeoptions) and Rewards

Started by mvstudio on 13 May 2019, 10:17 PM · Views: 16,038

Results 1 to 20 of 25
13 May 2019, 10:17 PM
#1
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Post #1 by mvstudio

Hello everyone,

I'm having a bit of an issue with the way freeoptions works and I really need some help.

I offer free shipping regardless of the product categories in the cart, to orders over $100. We also have implemented a Rewards Program that gives the customer points for every purchase that can be used to pay for future purchases (discount).

The problem is when the value of the reward points and the freeoptions are used together.

Say for example a customer has $100 worth of products in the cart, which qualifies him for free shipping, but he also uses the equivalent of $15 in reward points which discounts the subtotal for the order. As it is right now, the customer can still get free shipping even though the order has a discount of $15 and the total it's below the $100 minimum mark.

Is there any way to make freeoptions work with the total for the order rather than the subtotal??

Thanks in advance for the help =)

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com

14 May 2019, 10:34 AM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,146
Plugin Contributions:
56

Post #2 by lat9

What are the sort-orders for your active Modules->Order Total? Specifically, is the sort-order for Reward Points less than that for Shipping?

If not, perhaps making that change would allow the Reward Points module to do its calculations prior to those for *Shipping *and the issue might sort itself out.

14 May 2019, 1:07 PM
#3
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Post #3 by mvstudio

Hi lat9,
I have ot_shipping at 200 and ot_rewardpoints at 900.
I've played with the sort order and has no effect on it though. Free shipping still applies regardless of.

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com

14 May 2019, 1:29 PM
#4
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,146
Plugin Contributions:
56

Post #4 by lat9

mvstudio:

Hi lat9,
I have ot_shipping at 200 and ot_rewardpoints at 900.
I've played with the sort order and has no effect on it though. Free shipping still applies regardless of.
I've not used the Reward Points module, so I'm kind of "shooting in the dark" here, but if you want to have Free Shipping as the *only *shipping option for those orders > $100.00, you could configure the ot_shipping module to (a) allow free shipping and (b) set free shipping for orders over $100.00. If you do that, you'll want to remove/uninstall the *freeoptions *shipping method.

14 May 2019, 3:26 PM
#5
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Post #5 by mvstudio

Unfortunately ot_shipping with free shipping wouldn't work at all. It has its limitations when it comes to the weight of the package. We wouldn't be able to offer free shipping on a freight order for example.

The Free Shipping Option (ground shipping using the freeoptions) is offered additionally other shipping options (priority, express, fedex, etc.) based on (I was hopping) the order total and the weight of the package. I don't want to force customers a shipping option that's by definition the cheapest and the lowest (most of the time) when they can very well opt for a faster one or have their orders delivered overnight if they wish to do so even if that costs more. To me the option must always be with the client to select what works for them.

I'm trying to figure out if there is a way to change the way freeoptions calculates the total for the order or at least include a statement that if certain plugin is selected (like coupons or rewards) that modifies the order total, the a recalculation must take place. But my limited knowledge of PHP is kicking me in the face right now lol!

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com

22 May 2019, 4:35 AM
#6
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Post #6 by mvstudio

I was able to work something else which accomplishes the same result. Sort of.

For anyone interested...

In includes/templates/YOUR_TEMPLATE/template/tpl_checkout_confirmation_default.php

locate this

<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>
<div class="buttonRow"><?php echo TITLE_CONTINUE_CHECKOUT_PROCEDURE; ?></div>

and replace for this

<!-- bof disable checkout button on orders less than $100 -->
<?php
if (!IS_ADMIN_FLAG) { 
  global $order; 
  if ($order->info['total'] < 100) { 
	echo '<p style="text-align: center;border: 3px solid #777777; padding: 10px 0;"><strong>Your order does not qualify for Free Shipping at this time.</strong><br /><strong>Please go back to select another shipping option or add additional items to the shopping bag to meet the minimum order to qualify for free shipping.</strong></p>'; 
  } else {
?>
<!-- eof disable checkout button on orders less than $100 -->

<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>
<div class="buttonRow"><?php echo TITLE_CONTINUE_CHECKOUT_PROCEDURE; ?></div>

<!-- bof disable checkout button on orders less than $100 -->
<?php } } ?>
<!-- eof disable checkout button on orders less than $100 -->

What this code does is prevent placing the order by hiding the checkout button if order is less than $100. A message appears in place of the button with instructions to select another shipping option or add more products to the shopping cart. Maybe not the best or the most elegant solution but it works.

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com

22 May 2019, 1:03 PM
#7
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Post #7 by mvstudio

I made a change for it to work only if freeoptions is selected. My knowledge of php is very limited, so please feel free to correct/fix the code if it's ugly or needs to be improved.

<!-- bof disable checkout button on orders less than $100 and if freeoptions is selected  1 of 2 -->
<?php
if (!IS_ADMIN_FLAG) { 
  global $order; 
  if (($order->info['total'] < 100) && is_object ($freeoptions)) { 
    echo '<p style="text-align: center;border: 3px solid #777777; padding: 10px 0;"><strong>Your order does not qualify for Free Shipping at this time.</strong><br /><strong>Please go back to select another shipping option or add additional items to the shopping bag to meet the minimum order to qualify for free shipping.</strong></p>'; 
  } else {
?>
<!-- eof disable checkout button on orders less than $100 and if freeoptions is selected  1 of 2 -->

<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>
<div class="buttonRow"><?php echo TITLE_CONTINUE_CHECKOUT_PROCEDURE; ?></div>


<!-- bof disable checkout button on orders less than $100 and if freeoptions is selected  1 of 2 -->
<?php } } ?>
<!-- eof disable checkout button on orders less than $100 and if freeoptions is selected  1 of 2 -->

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com

12 Jul 2019, 2:52 PM
#8
monarchacct avatar

monarchacct

New Zenner

Join Date:
Jul 2019
Location:
Holyoke, MA
Posts:
7
Plugin Contributions:
0

Post #8 by monarchacct

mvstudio:

I made a change for it to work only if freeoptions is selected. My knowledge of php is very limited, so please feel free to correct/fix the code if it's ugly or needs to be improved.

<!-- bof disable checkout button on orders less than $100 and if freeoptions is selected 1 of 2 --> <?php if (!IS_ADMIN_FLAG) { global $order; if (($order->info['total'] < 100) && is_object ($freeoptions)) { echo '<p style="text-align: center;border: 3px solid #777777; padding: 10px 0;"><strong>Your order does not qualify for Free Shipping at this time.</strong><br /><strong>Please go back to select another shipping option or add additional items to the shopping bag to meet the minimum order to qualify for free shipping.</strong></p>'; } else { ?> <!-- eof disable checkout button on orders less than $100 and if freeoptions is selected 1 of 2 --> <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> <div class="buttonRow"><?php echo TITLE_CONTINUE_CHECKOUT_PROCEDURE; ?></div> <!-- bof disable checkout button on orders less than $100 and if freeoptions is selected 1 of 2 --> <?php } } ?> <!-- eof disable checkout button on orders less than $100 and if freeoptions is selected 1 of 2 -->

Hello!

First of all, I would like to thank you for your contribution! I'm not a PHP developer either, but your ideas pointed me in the right direction.

I did change your "if" statement to match our needs, so when the order is < $350 (our shop) AND the word "free" is present in the shipping method, it would display the warning. Otherwise, checkout would proceed as normal. It has worked out great for us.

if (($order->info['total'] < 350) && (stristr($order->info['shipping_method'], 'free', true))) {


I also added a link to the shipping options page to the text, made the border one point thicker, and made it red.

echo '<p style="text-align: center;border: 4px solid #ff0000; padding: 10px 0;"><strong>Your order does not qualify for Free Shipping at this time.</strong><br><strong>Please <a href="index.php?main_page=checkout_shipping"><u>go back to select another shipping option</u></a> or add additional items to the shopping cart<br>to meet the minimum order to qualify for free shipping.</strong></p>';


I still need to work with Ceon (we use Advanced Shipper) to make sure the free shipping option is not available if discounts bring the order below $350, but your contribution is a solid step in the right direction while that happens.

Once again, thank you!
15 Aug 2019, 7:09 PM
#9
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Post #9 by mvstudio

monarchacct:

Hello!

First of all, I would like to thank you for your contribution! I'm not a PHP developer either, but your ideas pointed me in the right direction.

I did change your "if" statement to match our needs, so when the order is < $350 (our shop) AND the word "free" is present in the shipping method, it would display the warning. Otherwise, checkout would proceed as normal. It has worked out great for us.

if (($order->info['total'] < 350) && (stristr($order->info['shipping_method'], 'free', true))) {

> 
> I also added a link to the shipping options page to the text, made the border one point thicker, and made it red.
> 
> ```
echo '<p style="text-align: center;border: 4px solid #ff0000; padding: 10px 0;"><strong>Your order does not qualify for Free Shipping at this time.</strong><br><strong>Please <a href="index.php?main_page=checkout_shipping"><u>go back to select another shipping option</u></a> or add additional items to the shopping cart<br>to meet the minimum order to qualify for free shipping.</strong></p>';

I still need to work with Ceon (we use Advanced Shipper) to make sure the free shipping option is not available if discounts bring the order below $350, but your contribution is a solid step in the right direction while that happens.

Once again, thank you!

So glad I could help and gave you the base to build up on it! :D

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com

12 Apr 2021, 4:41 PM
#10
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Post #10 by mvstudio

This is what happens when one has no clue what one is doing.... So I ran into a big issue.

The code I wrote now looks like this

<!-- 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 '<div style="border: 3px solid #777777; padding: 10px 0;"><p style="text-align: center;"><strong>Your order no longer qualifies for Free Shipping.</strong></p>
	<p style="text-align: center;"><strong>The total for your order is below the minimum qualifying for Free Shipping.</strong></p>
	<p style="text-align: center;"><strong>Please head back to the - <a href="index.php?main_page=shopping_cart">SHOPPING BAG</a> - to increase the quantity of products in your bag, add more products or select 
	a different shipping option.</strong></p>'; 
    echo'<span id="opc-order-confirm"></span>';  
  } else {
} ?>
<!-- eof disable checkout button from displaying  -->

The code works fine and does what it needs to do, but if a customer uses a gift certificate to pay for order, and if order falls below the threshold (gift certificates lower the amount as if it was a matter of a discount), customer cannot checkout.

How could I get the code to not be triggered when payment is in the form of gift certificate, partially or totally?

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com

12 May 2021, 9:28 PM
#11
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Post #11 by mvstudio

I've been cracking my head open trying to figure out a way around this and every time I get either a blank page.

<?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 '<div style="border: 3px solid #777777; padding: 10px 0;"><p style="text-align: center;"><strong>Your order no longer qualifies for Free Shipping.</strong></p>
	<p style="text-align: center;"><strong>The total for your order is below the minimum qualifying for Free Shipping.</strong></p>
	<p style="text-align: center;"><strong>Please head back to the - <a href="index.php?main_page=shopping_cart">SHOPPING BAG</a> - to increase the quantity of products in your bag, add more products or select 
	a different shipping option.</strong></p>'; 
    echo'<span id="opc-order-confirm"></span>'; 
    
	} elseif {  (($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_ORDER, BUTTON_CONTINUE_CHECKOUT_CONFIRMATION_ALT, 'name="btn_submit" id="btn_submit"') . '</div>';
 
  } else {
?>

What am I not getting right?... Could someone help me figure this out?...

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com

12 May 2021, 9:51 PM
#12
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #12 by mc12345678

mvstudio:

I've been cracking my head open trying to figure out a way around this and every time I get either a blank page.

<?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 '<div style="border: 3px solid #777777; padding: 10px 0;"><p style="text-align: center;"><strong>Your order no longer qualifies for Free Shipping.</strong></p> <p style="text-align: center;"><strong>The total for your order is below the minimum qualifying for Free Shipping.</strong></p> <p style="text-align: center;"><strong>Please head back to the - <a href="index.php?main_page=shopping_cart">SHOPPING BAG</a> - to increase the quantity of products in your bag, add more products or select a different shipping option.</strong></p>'; echo'<span id="opc-order-confirm"></span>'; } elseif { (($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_ORDER, BUTTON_CONTINUE_CHECKOUT_CONFIRMATION_ALT, 'name="btn_submit" id="btn_submit"') . '</div>'; } else { ?>
> 
> What am I not getting right?... Could someone help me figure this out?...
If you get a blank page, there should be a nifty myDebug log file in your logs folder waiting to identify what is wrong with the code... The information contained therein will be the best source of help. Now, I do see an issue with the code above:

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

should be more like:

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

though there may be other issues within there or elsewhere... But that extra left curly brace with no "if criteria" will certainly cause an issue.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

13 May 2021, 5:35 PM
#13
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Post #13 by mvstudio

mc12345678:

If you get a blank page, there should be a nifty myDebug log file in your logs folder waiting to identify what is wrong with the code... The information contained therein will be the best source of help. Now, I do see an issue with the code above:

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

> should be more like:
> ```
elseif  (($order->info['total'] < MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN) && (substr_count($_SESSION['shipping']['id'], 'freeoptions') !=0) && ($_SESSION['cot_gv'] !=0)) {

though there may be other issues within there or elsewhere... But that extra left curly brace with no "if criteria" will certainly cause an issue.

Thank you!!!!

I'm finally not getting the blank page, but the code doesn't work, so I now need to figure out how to insert the proper gv statement, for which I still have no clue.

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com

14 May 2021, 7:59 PM
#14
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Post #14 by mvstudio

This is driving me bananas, and for sure is something simple, I just don't know enough to figure it out. :no: Could anyone throw me a clue please?...

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com

14 May 2021, 10:41 PM
#15
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #15 by mc12345678

could you be more specific about "doesn't work"? I didn't even really look at what the code is expected to do, but instead the syntax of it because its just a snippet of the whole. Further this area of code in the bigger picture has/does not have certain data available depending on what page is being viewed and other things.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

15 May 2021, 2:57 PM
#16
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Post #16 by mvstudio

mc12345678:

could you be more specific about "doesn't work"? I didn't even really look at what the code is expected to do, but instead the syntax of it because its just a snippet of the whole. Further this area of code in the bigger picture has/does not have certain data available depending on what page is being viewed and other things.

Sorry! I forgot to add what doesn't work.

What I'm trying to accomplish is turning off, so to speak the ability for customers to place the order if certain conditions aren't met. The code is placed in the tpl_checkout_confirmation_default.php page right above the place order button.

The original code, which I came up with worked... up to a point. Basically this checks if free options total minimum is met based on the total of the order, and if it's not met, then trigger a message instructing the customer his/her order no longer qualifies for free shipping.

ORIGINAL CODE

<?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 TO BE DISPLAYED';  
    
  } else {
?>

The reason for this is because free shipping option is calculated on sub-total nor total, so customers were applying discounts lowering the minimum for free shipping and still getting free shipping. Not ideal.

But, the problem I have with this piece of code, is that customers paying with gift certificates, which is technically cash, are still unable to checkout, as the total of the order is actually lowered triggering the message the order no longer qualifies for free shipping.

So I thought adding an elseif statement that if the above happens and gift certificates are used to pay for the order, then the message isn't triggered and customer can still checkout and get free shipping. However the way I wrote it, doesn't seem to accomplish anything at all.

MODIFIED CODE THAT DOESN'T WORK AS INTENDED

<?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';  

} elseif (($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_ORDER, BUTTON_CONTINUE_CHECKOUT_CONFIRMATION_ALT, 'name="btn_submit" id="btn_submit"') . '</div>';
    
  } else {
?>

The part I need help with is the elseif statement on the code above to let customers checkout if the order which qualified for free shipping to begin with is also paid with gift certificate.

Sorry for the long explanation.

Thank you for helping me out! :smile:

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com

15 May 2021, 5:07 PM
#17
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #17 by mc12345678

No, the detail was very helpful.

Now to see how I can explain how to address the issue, why the desired results are not being seen, what was not quite being considered correctly.

So, it seems the issue is that there are conditions at which the "standard" process doesn't give the desired results. Lets just consider the cases where the cart total was above the minimum desired, but some extra feature drove the total below the desired amount.

The desire is to allow the situations where ones own money is being used, but to stop the situations where the store is "giving" money.

The two conditions identified right now for that to happen are gift certificates (one's own money) and coupons (the store's money). Both of these cause the total to go below the threshold.

Ok, on the same page right?

Well, thing is, that logic needs to be considered in addressing the handling of the new situation.

Now there are at least two ways that come to mind on how to address it. I have a preference, but it also can depend on how complicated the follow-on action is.

So, the first and my preferred at the moment, is to keep your existing initial evaluation: if the price is lower than it should be, enter this area of evaluation.

Now check why it is low, if it is because of a gift certificate, then continue in a positive direction, allowing the customer to checkout and bypass any "stop" code. The action to otherwise occur is the stop code and message. I leave the coding logic to whatever you choose, but generally speaking the easier it is to read, the easier it is to follow/modify in the future.

The other alternative is to continue with these multiple ifs/elseifs... in the situation described above, because both situations cause the total to be too low, then the action that is to be allowed, should be evaluated first. If the value is low because a gift certificate hasn't been used, then the next thing to consider is if the value is low at all and if so, to stop execution.

Note, that this logic is also dependent on only one or the other being used... for example, what is the handling if the total is low because both a gift certificate AND a coupon was used?

Reviewing that on an if statement may be a lot of work. Afterall, its not necessarily a check that a gift certificate was used at all, but even if one or more gift certificates were used, do their total used value plus the current total equal or exceed the lower limit?

Anyways, what I'm getting at is with the new criteria attempted to be used and based on what drives the problem, the first if is always true when using a gift certificate or coupon and therefore the elseif is never reached. Swapping the order of the checks would at least allow evaluation of the gift certificate aspect such that if it isn't the cause the next check is executed which would identify that it is low and then execute.

Alternatively, as in my first example (preferred), the final value is low, now within that area, further evaluation can be done to determine why it is low and if it is ok to be low, carry on if not then "stop".

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

19 May 2021, 12:58 PM
#18
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Post #18 by mvstudio

mc12345678:

No, the detail was very helpful.

Now to see how I can explain how to address the issue, why the desired results are not being seen, what was not quite being considered correctly.

So, it seems the issue is that there are conditions at which the "standard" process doesn't give the desired results. Lets just consider the cases where the cart total was above the minimum desired, but some extra feature drove the total below the desired amount.

The desire is to allow the situations where ones own money is being used, but to stop the situations where the store is "giving" money.

The two conditions identified right now for that to happen are gift certificates (one's own money) and coupons (the store's money). Both of these cause the total to go below the threshold.

Ok, on the same page right?

Well, thing is, that logic needs to be considered in addressing the handling of the new situation.

Now there are at least two ways that come to mind on how to address it. I have a preference, but it also can depend on how complicated the follow-on action is.

So, the first and my preferred at the moment, is to keep your existing initial evaluation: if the price is lower than it should be, enter this area of evaluation.

Now check why it is low, if it is because of a gift certificate, then continue in a positive direction, allowing the customer to checkout and bypass any "stop" code. The action to otherwise occur is the stop code and message. I leave the coding logic to whatever you choose, but generally speaking the easier it is to read, the easier it is to follow/modify in the future.

The other alternative is to continue with these multiple ifs/elseifs... in the situation described above, because both situations cause the total to be too low, then the action that is to be allowed, should be evaluated first. If the value is low because a gift certificate hasn't been used, then the next thing to consider is if the value is low at all and if so, to stop execution.

Note, that this logic is also dependent on only one or the other being used... for example, what is the handling if the total is low because both a gift certificate AND a coupon was used?

Reviewing that on an if statement may be a lot of work. Afterall, its not necessarily a check that a gift certificate was used at all, but even if one or more gift certificates were used, do their total used value plus the current total equal or exceed the lower limit?

Anyways, what I'm getting at is with the new criteria attempted to be used and based on what drives the problem, the first if is always true when using a gift certificate or coupon and therefore the elseif is never reached. Swapping the order of the checks would at least allow evaluation of the gift certificate aspect such that if it isn't the cause the next check is executed which would identify that it is low and then execute.

Alternatively, as in my first example (preferred), the final value is low, now within that area, further evaluation can be done to determine why it is low and if it is ok to be low, carry on if not then "stop".

Thank you so much!! It never occurred to me flipping the statements would even make a difference, and I'm happy to report it works!!

If customer pays with GV the button is displayed. If customer uses reward points or coupons that lower the amount the buttons aren't displayed and the message to add more items, change quantities to reach the minimum threshold for free shipping or selecting a different shipping option is triggered.

However in running the tests I stumbled on a new occurrence I hadn't considered before. What if the customer uses both? A coupon or reward points (customers can't use both in my store, is either one or the other) which lower the total amount, and customer pays with a GV, and my code failed.

I offer free shipping on orders over $99.99
Customer has $100.75 in the cart.
Discount coupon or reward points in the amount of $5 lowering the total to below the minimum required for free shipping to $95.75.
Customer can still checkout even though minimum order for free shipping hasn't been met.

Not a clue how to tackle this one :ohmy:

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com

19 May 2021, 6:05 PM
#19
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Post #19 by mvstudio

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.

<!-- 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_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)) { 
	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.

      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';

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com

26 May 2021, 1:23 PM
#20
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Post #20 by mvstudio

Could anyone give me a clue on how to approach this? I really am stuck as I don't know much php. Any help is appreciated.

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com