Octane Posted February 5, 2014 Share Posted February 5, 2014 I have a certain product that cannot be sent by airmail. I am trying to modify my shipping module to throw an error if this product is in their cart. My php skills are very basic. Please excuse the stupid question. I do need to sort this out though. I've tried the following: $foundproduct = false; if (in_array("product", $order)) { $foundproduct = true; } This gives me the following error: Warning: in_array() [function.in-array]: Wrong datatype for second argument in catalog/includes/modules/shipping/salargeparcel.php on line 186 Can someone please give me the correct php? Thanks Quote Link to comment Share on other sites More sharing options...
burt Posted February 5, 2014 Share Posted February 5, 2014 (edited) $foundproduct = false; if (in_array(X, $cart->get_products())) { $foundproduct = true; } Change X to the ID of the product. What you do with foundproduct = true is up to you. Edit: you might needf to global the $cart in the shipping module Edited February 5, 2014 by burt Quote Link to comment Share on other sites More sharing options...
Octane Posted February 5, 2014 Author Share Posted February 5, 2014 Thanks for the quick reply. I still can't seem to get it to work. This is the code I've got: $foundultra = false; if (in_array("Ultra Race Fuel Concentrate", $cart->get_products())) { $foundultra = true; } However when I test for it, it always tests false. The product is in the array: print_r ($cart->get_products()); Array ( [0] => Array ( [id] => 31 [name] => Street Octane Booster [model] => 3 RON [image] => Street.jpg [price] => 50.0000 [quantity] => 1 [weight] => 0.22 [final_price] => 50 [tax_class_id] => 0 [attributes] => ) [1] => Array ( [id] => 29 [name] => Ultra Race Fuel Concentrate [model] => 6-10 RON [image] => Ultra.jpg [price] => 250.0000 [quantity] => 1 [weight] => 1.15 [final_price] => 250 [tax_class_id] => 0 [attributes] => ) ) This shouldn't be that difficult. I'm wondering about myself today. Quote Link to comment Share on other sites More sharing options...
Octane Posted February 5, 2014 Author Share Posted February 5, 2014 This is what I'm trying to do: if (in_array("Ultra Race Fuel Concentrate", $cart->get_products())) { $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_SALARGEPARCEL_TEXT_TITLE, 'methods' => array(array('title' => $this->quotes['error']))); $this->quotes['error'] = 'NF Ultra Race Fuel Concentrate cannot be shipped by airmail.'; return $this->quotes; } Quote Link to comment Share on other sites More sharing options...
♥GLWalker Posted February 5, 2014 Share Posted February 5, 2014 Ultra Race Fuel Concentrate will always return false, you have to use the product ID, if more than 1 product you'll need to comma seperate the id's and explode them. Read this thread for help, a lot of the code you need is written, just needs slight modification: http://www.oscommerce.com/forums/topic/395429-restricting-certain-products-from-paypal-payments/ Octane 1 Quote Follow the community build: BS3 to osCommerce Responsive from the Get Go! Check out the new construction: Admin Gone to Total BS! Link to comment Share on other sites More sharing options...
Octane Posted February 6, 2014 Author Share Posted February 6, 2014 Thank you WebSource 5, that gave me the info I needed. I got it working. Here is my final source: $products = $cart->get_products(); for ($i=0, $n=sizeof($products); $i<$n; $i++) { if ($products[$i]['name']=="Ultra Race Fuel Concentrate") { $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_SALARGEPARCEL_TEXT_TITLE, 'methods' => array(array('title' => $this->quotes['error']))); $this->quotes['error'] = 'NF Ultra Race Fuel Concentrate cannot be shipped by airmail.'; return $this->quotes; } } 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.