/* This macro will be parsed as PHP code (see http://www.php.net) The calculateshipping function is called every time a shipping calculation request is made by Shopify. The function must return an array of available shipping options, otherwise no shipping options will be returned to your customers. */ function calculateshipping($DATA) { /* do not edit above this line */ $_RATES = array(); $restrictedItems = getcollection(123456789); //enter your collectionid (to get the collectionid, goto your Shopify admin > products > collections > click on the collection > read the numbers off the end of the URL) $freeShippingThreshold = 150; //this is before discounts $containsRestricted = false; $t = 0; foreach ($DATA['items'] as $item) { if (in_array($item['product_id'],$restrictedItems)) $containsRestricted = true; $t += $item['quantity']*$item['price']/100; } if (!$containsRestricted && $t > $freeShippingThreshold) { $_RATES[] = array( "service_name" => "Free Shipping", //this is what the customer will see "service_code" => "Free Shipping", //can be anything you like "total_price" => 0, //in cents "currency" => "USD", ); } return $_RATES; /* do not edit below this line */ }