zpupster Posted April 13, 2017 Share Posted April 13, 2017 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 Quote Link to comment Share on other sites More sharing options...
zpupster Posted April 13, 2017 Author Share Posted April 13, 2017 am i at the right forum section?? Quote Link to comment Share on other sites More sharing options...
Psycho Posted April 13, 2017 Share Posted April 13, 2017 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? Quote Link to comment Share on other sites More sharing options...
maxxd Posted April 13, 2017 Share Posted April 13, 2017 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.