Re: USPS Shipping Module [Support Thread]
Quote:
Originally Posted by
lat9
... and what are "the statements that should be able to find it"?
I'm still using the old usps.php module, since it includes filters that I set up years ago. I have not been able to figure out how to add those filters to the new code, or I'd have already done that. I'll list a couple of lines of the code below, but it is working just fine for every single product id that I add, except for one. The only thing I can think of is that there is some invisible character in the product id that's causing it not to be recognized. I've confirmed that I can substitute any other product id in our inventory, and the code does as it always has done for those id's, just not for this one particular item.
Code:
//bof: example to block USPS PriorityMailTM Flat Rate Padded Envelope when certain products are in the cart
if (true) {
$chk_cart_env = 0;
$chk_cart_env += $_SESSION['cart']->in_cart_check('master_categories_id','1'); // Golden paste
$chk_cart_env += $_SESSION['cart']->in_cart_check('master_categories_id','2'); // spices
$chk_cart_env += $_SESSION['cart']->in_cart_check('master_categories_id','3'); // accessories
$chk_cart_env += $_SESSION['cart']->in_cart_check('master_categories_id','5'); // livestock feed
$chk_cart_env += $_SESSION['cart']->in_cart_check('master_categories_id','10'); // oils
$chk_cart_env += $_SESSION['cart']->get_quantity('76') > 0; // original bar
$chk_cart_env += $_SESSION['cart']->get_quantity('78') > 0; // ginger bars
$chk_cart_env += $_SESSION['cart']->get_quantity('150') > 0; // One of each of the turmeric bars
$chk_cart_env += $_SESSION['cart']->get_quantity('166') > 0; // ChickiBams box of 20
$chk_cart_env += $_SESSION['cart']->get_quantity('167') > 0; // WhamBams box of 20
$chk_cart_env += $_SESSION['cart']->get_quantity('168') > 0; // GingiBams box of 20
$chk_cart_env += $_SESSION['cart']->get_quantity('161') > 0; // PawSkin
$chk_cart_env += $_SESSION['cart']->get_quantity('171') > 0; // Snack Pack
This works to prevent the customer from choosing a flat rate padded envelope for every single product code except the last one in the list. No matter what I do, that one is being ignored. I need to know what product id the code is actually finding there so hopefully I can tell why it's falling through the last statement with a zero value when the quantity is greater than zero. And yes, I'm aware that there is no ending curly brace, This is just a snippet.
Re: USPS Shipping Module [Support Thread]
That functionality, in more current versions of USPS, is available via a site-specific observer's processing. See https://github.com/lat9/usps/blob/K1..._overrides.php for an example
Re: USPS Shipping Module [Support Thread]
Quote:
Originally Posted by
lat9
Yes, I know that, but I have never been able to make it work. The only way I've been able to manage the appropriate size shipping service for our products is to stay with the existing working code. I just need to know what variable to look at to see what Zencart thinks the product ID is here.
Re: USPS Shipping Module [Support Thread]
Quote:
Originally Posted by
HeleneWallis
Yes, I know that, but I have never been able to make it work. The only way I've been able to manage the appropriate size shipping service for our products is to stay with the existing working code. I just need to know what variable to look at to see what Zencart thinks the product ID is here.
You'd just follow the "pattern" in that extras file, using (most likely)
Code:
$_SESSION['cart']->in_cart_check('master_categories_id', {product-id to be checked});
Re: USPS Shipping Module [Support Thread]
Quote:
Originally Posted by
lat9
You'd just follow the "pattern" in that extras file, using (most likely)
Code:
$_SESSION['cart']->in_cart_check('master_categories_id', {product-id to be checked});
That just returns a zero, since there is no master category with that number. I don't see how it could work, since I'm not looking at a master category of 171, but a product id of 171.
Re: USPS Shipping Module [Support Thread]
Quote:
Originally Posted by
HeleneWallis
That just returns a zero, since there is no master category with that number. I don't see how it could work, since I'm not looking at a master category of 171, but a product id of 171.
try:
PHP Code:
$_SESSION['cart']->in_cart_check('products_id', {product-id to be checked});
best.
Re: USPS Shipping Module [Support Thread]
Quote:
Originally Posted by
carlwhat
try:
PHP Code:
$_SESSION['cart']->in_cart_check('products_id', {product-id to be checked});
best.
That is giving me the quantity of that product number in the cart, which I also needed to know. But not the actual product number itself. But it does confirm that the software is seeing '171' as the product ID, because it returns the correct quantity. So I am still totally stumped as to why this is happening:
Code:
echo $_SESSION['cart']->get_quantity('171'); // RETURNS ZERO
echo $_SESSION['cart']->in_cart_check('products_id', '171'); // RETURNS 1, WHICH IS CORRECT
The first comparison works for every single other product id in our inventory, but not for the one with an id of 171. That's why I was trying to find out what the code was actually seeing there. The second statement confirms that it is seeing 171. I can use the second comparison as a workaround, but the first one ought to work.
Re: USPS Shipping Module [Support Thread]
looking at the code is always a good idea. in this case, there is useful info in the documentation of the code.
the following snippet is from:
includes/classes/shopping_cart.php
PHP Code:
/**
* Get the quantity of an item in the cart
* NOTE: This accepts attribute hash as $products_id, such as: 12:a35de52391fcb3134
* ... and treats 12 as unique from 12:a35de52391fcb3134
* To lookup based only on prid (ie: 12 here) regardless of the attribute hash, use another method: in_cart_product_total_quantity()
*
* @param int|string $uprid product ID of item to check
* @return int|float the quantity of the item
*/
public function get_quantity($uprid)
i would use the method:
in_cart_product_total_quantity()
instead of
get_quantity()
and see if that provides the desired results.
best.
Re: USPS Shipping Module [Support Thread]
Quote:
Originally Posted by
carlwhat
looking at the code is always a good idea. in this case, there is useful info in the documentation of the code.
the following snippet is from:
includes/classes/shopping_cart.php
PHP Code:
/**
* Get the quantity of an item in the cart
* NOTE: This accepts attribute hash as $products_id, such as: 12:a35de52391fcb3134
* ... and treats 12 as unique from 12:a35de52391fcb3134
* To lookup based only on prid (ie: 12 here) regardless of the attribute hash, use another method: in_cart_product_total_quantity()
*
* @param int|string $uprid product ID of item to check
* @return int|float the quantity of the item
*/
public function get_quantity($uprid)
i would use the method:
in_cart_product_total_quantity()
instead of
get_quantity()
and see if that provides the desired results.
best.
Thank you, that is working.
I know I have to get the newer code set up, but I simply do not have time to do it, and as long as this is working for now, it will have to do.
Re: USPS Shipping Module [Support Thread]
Today we noticed intermittent issues of getting: "Your order's details have changed. Please review the current values and re-submit." Reloading the page or changing the shipping method will let the order go through. Only recent changes were upgrading USPS from K11i to K11j (I typed in the password), sitemap from 3.99 to 4, GPSF from 1.0.0 to 1.0.1, and edit orders from 4.7.0beta2 to 4.7.0 released. It happens using cashiers check / money order, so not a payment module issue.
Guessing USPS API issue? Anyone else seeing this?