Jump to content

if statement no free shipping


zpupster

Recommended Posts

trying to emulate this code:

it says if the module is marked true, then drop all items with special prices from free shipping.

    if (MODULE_SHIPPING_FREEAMOUNT_HIDE_SPECIALS == 'True') {
      if ($cart->count_contents() > 0) {
        $products = $cart->get_products();
        for ($i=0, $n=sizeof($products); $i<$n; $i++) {
          if ($special_price = tep_get_products_special_price($products[$i]['id'])) {
            $cart_total -= ($special_price * $products[$i]['quantity']);
          }
        }
      }
    }

my situation is if the category id is greater than 188( for now just greater than 188) and less than a category to be determined( tbd) drop from free shipping.  this is what i have, i wrote a new query getting the category id and trying to compare it to 188.  i know it is sloppy but my skill level is not quite there yet.  hence i am asking for help.

 

 

$hide_query = tep_db_query("select categories_id from categories where  categories_id => 188 ");


   if ('MODULE_XTR_SHIPPING_HIDE_FREEAMOUNT' == 'True') {
      if ($cart->count_contents() > 0) {
        $products = $cart->get_products();
        for ($i=0, $n=sizeof($products); $i<$n; $i++) {
          if ($hide_query = tep_get_products_special_price($products[$i]['id'])) {
            $cart_total -= ($hide_query * $products[$i]['quantity']);
          }
        }
      }
    }

ty

 

Link to comment
Share on other sites

Yes, it is the right forum. But, from what you have posted, it is difficult to provide a valid response. There are custom methods in that code which we are not privy to. Plus, there are some things that don't make any sense to me. So, either the code is 'bad' or there is more going on than I know.

 

What kind of value does $hide_query hold? You're using a function/method that is running a query and returning something.

 

Is $products and array? If so, the for() loop should just be a foreach() loop.

 

This condition is likely wrong

 

if ($hide_query = tep_get_products_special_price($products[$i]['id'])) {

I assume you want to TEST if the values are equal and should be using double equal signs and not doing an ASSIGNMENT with a single equal sign.

 

I;m really not sure how to interpret this

 

$cart_total -= ($hide_query * $products[$i]['quantity']);

I guess $hide_query should be a number value (possibly a category ID?). But, why would the ID be multiplied by the quantity?

Link to comment
Share on other sites

Also, this line

if ('MODULE_XTR_SHIPPING_HIDE_FREEAMOUNT' == 'True') {

is never going to equate to true, because you're comparing visibly different strings. I think you mean MODULE_XTR_SHIPPING_HIDE_FREEAMOUNT to be a constant, thus

if(MODULE_XTR_SHIPPING_HIDE_FREEAMOUNT){

is what you're looking for. And why are you assigning $hide_query the result of a query that apparently returns multiple product ids, only to overwrite it with the result of a method call that apparently returns a price?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.