Helene, that looks like it should work. There's a specific naming convention for auto-loaded observer-class modules.
What's the name of the auto.*.php class file and the name of the class (i.e. class ClassName)?
Helene, that looks like it should work. There's a specific naming convention for auto-loaded observer-class modules.
What's the name of the auto.*.php class file and the name of the class (i.e. class ClassName)?
Helene, edit /includes/modules/shipping/usps.php to locate its install function. You'll see a section of code like the following (which is K11i):
Don't pay attention to the various \' elements (they're needed for the database insert), but those strings identify the various USPS shipping methods supported by the shipping module.Code:$db->Execute( "INSERT INTO " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Shipping Methods (Domestic and International)', 'MODULE_SHIPPING_USPS_TYPES', '0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, 0, .21875, 0.00, 0, 4, 0.00, 0, 4, 0.00, 0, 66, 0.00, 0, 4, 0.00, 0, 4, 0.00, 0, 20, 0.00, 0, 20, 0.00, 0, 66, 0.00, 0, 4, 0.00, 0, 70, 0.00, 0, 70, 0.00', '<b><u>Checkbox:</u></b> Select the services to be offered<br><b><u>Minimum Weight (lbs)</u></b>first input field<br><b><u>Maximum Weight (lbs):</u></b>second input field<br><br>USPS returns methods based on cart weights. These settings will allow further control (particularly helpful for flat rate methods) but will not override USPS limits', 6, 0, 'zen_cfg_usps_services([\'Media Mail Parcel\', \'USPS Ground AdvantageTM\', \'Priority MailRM\', \'Priority MailRM Flat Rate Envelope\', \'Priority MailRM Legal Flat Rate Envelope\', \'Priority MailRM Padded Flat Rate Envelope\', \'Priority MailRM Small Flat Rate Box\', \'Priority MailRM Medium Flat Rate Box\', \'Priority MailRM Large Flat Rate Box\', \'Priority Mail ExpressRM\', \'Priority Mail ExpressRM Flat Rate Envelope\', \'Priority Mail ExpressRM Legal Flat Rate Envelope\', \'First-Class MailRM International Letter\', \'First-Class MailRM International Large Envelope\', \'First-Class Package International ServiceTM\', \'Priority Mail InternationalRM\', \'Priority Mail InternationalRM Flat Rate Envelope\', \'Priority Mail InternationalRM Small Flat Rate Box\', \'Priority Mail InternationalRM Medium Flat Rate Box\', \'Priority Mail InternationalRM Large Flat Rate Box\', \'Priority Mail Express InternationalRM\', \'Priority Mail Express InternationalRM Flat Rate Envelope\', \'USPS GXGTM Envelopes\', \'Global Express GuaranteedRM (GXG)\'], ', now())" );
Cindy, what am I missing here? The logic is obvious but it isn't working. For example, in the sample included in auto.usps_overrides.php, $p1 should be (or at least include) the string 'Media Mail,' isn't that correct? So in my addition using 'Priority MailRM Small Flat Rate Box,' $p1 should be (or include) that string. But it clearly does not, since the conditional statement is failing.
I corrected my code to read
since I want to exclude that shipping method if anything in the cart falls in the specified categories. But this is still permitting a customer to choose a small flat rate box for items in those categories.PHP Code:
if (stripos($p1, 'Priority MailRM Small Flat Rate Box') !== false) {
$chk_cart = 0;
$chk_cart += $_SESSION['cart']->in_cart_check('master_categories_id','1'); // golden paste
$chk_cart += $_SESSION['cart']->in_cart_check('master_categories_id','2'); // spices
$chk_cart += $_SESSION['cart']->in_cart_check('master_categories_id','3'); // accessories
$chk_cart += $_SESSION['cart']->in_cart_check('master_categories_id','5'); // livestock feed
$chk_cart += $_SESSION['cart']->in_cart_check('master_categories_id','10'); // oils
$chk_cart += $_SESSION['cart']->in_cart_check('master_categories_id','11'); // pet products
$chk_cart += $_SESSION['cart']->get_quantity('148') > 0; // Soothamide
if ($chk_cart > 0) {
$p2 = false;
}
}
break;
Hi Helen,
have you checked that $p1 is as you expect? Either using a debugging tool that will allow you to see the value of $p1 or by adding a line to the code to echo the value of $p1 so you can confirm you have the correct string.
Also don't think it is the issue, but you could change
toCode:$chk_cart += $_SESSION['cart']->get_quantity('148') > 0; // Soothamide
As get_quantity, return 0 if it doesn't find the product in the cart.Code:$chk_cart += $_SESSION['cart']->get_quantity('148'); // Soothamide
Mark Brittain
http:\\innerlightcrystals.co.uk\sales\
I attempted to use echo to see $p1, but it isn't showing up. In fact, I'm not certain the file is even being seen, because nothing I do to it, including deliberate syntax errors, make any difference.
Thank you for the modification on the Soothamide line. But that isn't the problem. It isn't ever getting executed.
I assume that if you go to the cart, the UPS postage option is there.
If that is true, I assume that you viewed the page source to look for the echo you put in.
To check the observer is being loaded. If you put a syntax error into auto.usps_overrides.php you should get a white screen when trying to check out. (the auto.usps_overrides.php should be present in includes/classes/observers) if you are not getting a white screen, then the file is not being loaded.
Sorry not in the US so I do not have an account to test.
Mark Brittain
http:\\innerlightcrystals.co.uk\sales\
... and the file is present in /includes/classes/observers/auto.usps_overrides.php?
Bookmarks