Oscommerce 2.2 RC 2A
Extensive knowledge of oscommerce required, and access to your own dev environment, as access to our installation will not be provided.
Goal: Show USPS First Class Mail as an option only, for products flagged as allowing it.
- Avoid using oscommerce contributions such as MVS.
- Below is code I have so far, that comes from a modified /includes/modules/shipping/usps.php
Need help looping through shopping cart, to check that each item has flag set to 1. If all have flag set to 1, I show quotes for the first class mail option
//If the weight of this product is 1 pound, it has the potential for first class.
//1 pound is the tare weight, and we subtract 1 lb for first class mail to leave only ounces
if ($this->pounds == “1″)
{
//Section that does not work; Loop through shopping cart – check all products
//Array Wrong Data Type
$check_first_class_basket_query = tep_db_query(“select products_id from ” . TABLE_CUSTOMERS_BASKET . ” where customers_id = ‘” . (int)$customer_id . “‘”);
while ($check_first_class_basket = tep_db_fetch_array($check_first_class_basket_query))
{
$check_first_class_query = tep_db_query(“select products_free_shipping from ” . TABLE_PRODUCTS . ” where products_id = ‘” . (int)$check_first_class_basket['products_id'] . “‘”);
$check_first_class = tep_db_fetch_array($check_first_class_query);
$check_first_class_array[] = $check_first_class['products_free_shipping'];
}
if (in_array(“1″, $check_first_class_array) && !in_array(“0″, $check_first_class_array))
{
//End Section that does not work. LOL.
//If ounces = 0, we change the weight to 1 ounce (the minimum)
if ($this->ounces == “0″)
{
$request .= ‘<Pounds> 0 </Pounds>’ . ‘<Ounces>1</Ounces>’;
}
else
{
$request .= ‘<Pounds> 0 </Pounds>’ . ‘<Ounces>’ . $this->ounces . ‘</Ounces>’;
}
}
}//Package is greater then 1 pound, skip the above checks.
}
else //KEY != FIRST CLASS