Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function products_shipping_total($total = null, $order_id = null, $order = null, $items = array(), $shipmethod = null) {
- global $wpcoDb, $Order, $Item, $Product, $wpcoShipmethod;
- $productsshipping = 0;
- if (!empty($order_id)) {
- if (!empty($order)) {
- if (!empty($shipmethod)) {
- if (!empty($items)) {
- foreach ($items as $item) {
- if (!empty($item -> product -> type) && $item -> product -> type == "tangible") {
- //BEG additional product shipping cost
- if (!empty($item -> product -> shipping) && $item -> product -> shipping == "Y") {
- if (!empty($item -> product -> shiptype)) {
- switch ($item -> product -> shiptype) {
- case 'tiers' :
- if (!empty($item -> product -> shiptiers) && is_array($item -> product -> shiptiers)) {
- $s = 1;
- foreach ($item -> product -> shiptiers as $tier) {
- if (($item -> count >= $tier['min'] && $item -> count <= $tier['max']) || $s == count($item -> product -> shiptiers)) {
- $productsshipping += ($tier['price'][$order -> shipmethod_id] * $item -> count);
- break 1;
- }
- $s++;
- }
- }
- break ;
- case 'percentage' :
- global $Product;
- if (!empty($item -> product -> shippercentage) && is_array($item -> product -> shippercentage)) {
- if (!empty($item -> product -> shippercmethod)) {
- if ($item -> product -> shippercmethod == "wholesale" && !empty($item -> product -> wholesale)) {
- $newproductshipping = ((($item -> product -> wholesale * $item -> product -> shippercentage[$shipmethod -> id]) / 100) * $item -> count);
- } elseif ($item -> product -> shippercmethod == "fixed") {
- $newproductshipping = ((($Product -> unit_price($item -> product -> id, $item -> count, $item -> id, false, true) * $item -> product -> shippercentage[$shipmethod -> id]) / 100) * $item -> count);
- }
- if (!empty($newproductshipping)) {
- $productsshipping += $newproductshipping;
- }
- }
- }
- break;
- default :
- if (!empty($item -> product -> shipfixed) && is_array($item -> product -> shipfixed)) {
- $productsshipping += ($item -> product -> shipfixed[$shipmethod -> id] * $item -> count);
- }
- break ;
- }
- }
- }
- //END additional product shipping cost
- }
- }
- }
- }
- }
- }
- return $productsshipping;
- }
Advertisement
Add Comment
Please, Sign In to add comment