PatrickPeeters Posted June 21, 2012 Share Posted June 21, 2012 I'm offering Pickup and Shipping on my site. For products which I can do both it works. I want some products never to be shipped, because their simply to heavy. So if I can hide shipping for products that are way to heavy for shipment and only display pickup as an option. It works if I let OSC 2.2 do it on price, with the following code in the shipping module. if ( ($this->enabled == true) && ($order->info['total']>= 100) ) { $this->enabled = false; } What would be to code to do it base on weight? This doesn't seem to work for me: if ( ($this->enabled == true) && ($shipping_weight >= 100) ) { $this->enabled = false; Should be easy feeling kinda stupid that nothing seems to work! Quote Link to comment Share on other sites More sharing options...
multimixer Posted June 21, 2012 Share Posted June 21, 2012 (edited) Did you declare anywhere what $shipping_weight is ? How should the system know that you mean the total weight of the order (or maybe a specific product - you didn't make this clear) ? PHP does not speak english, so just because you call your variable $shipping_weight, it means nothing. You could call it $kuku, but you need to say what it is In the condition you had in your old store ( $order->info['total']>= 100 ), the system "go" to class order, that is in file includes/classes/order.php and pulls the value from there. The value get calculated at the bottom of the file and added to the array named "info", so you can use $order->info['total'] Right now, there is no such calculation for the total weight of a order, but there is a value for the weight of a specific product. So you could have $order->products[$i]['weight'] To use this, you need to loop through all products of an order of course (that is the meaning of the $i, it count each element of the products array In case you need the total weight of an order, you would need to add up the weight for each product and return a new value for total_weight or something You can see how this is done for the subtotal ( $this->info['subtotal'] += $shown_price; ) and do the same for the weight UPDATE: The cart class calculates already the weight, so you could use that Edited June 21, 2012 by multimixer Quote My community profile | Template system for osCommerce - New: Responsive | Feedback channel Link to comment Share on other sites More sharing options...
PatrickPeeters Posted June 21, 2012 Author Share Posted June 21, 2012 (edited) I did add the $shipping_weight in the table shipping option. The tableshipping option can calculate the shippingcosts based on price or weight. Some smart guys figured out posted it on the web, that the shipping is based on weight if the product has a weight configured and that works nicely. (except I have non shippable cheap items that's a problem) so I figured out if I can hide the shipping option by maximum weight and fill in the weight of a product that i do not want ship, and make all those products very heavy it won't show up if in the cart is one of them. I'm not a php guru but somehow after some tinkering it now works!! I'm clueless why. I seen a lot of people asking for it but no real answer. used this code on : var $code, $title, $description, $icon, $total_weight, $enabled; if ( ($this->enabled == true) && ($shipping_weight >= 100) ) { $this->enabled = false; The shipping_weight option was allready in the code default, because of the table shipping calculation option needs the weight to figure out shipping. Edited June 21, 2012 by PatrickPeeters 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.