Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. if ($_SESSION["sample_count"] == $_SESSION["cart_items_count"]){
  2.  
  3. $sample_count = $_SESSION["sample_count"];
  4. $sample_shipping_cost = 4;
  5. $woocommerce->cart->add_fee( 'Samples Postage', ($sample_count * 4), true, '' );
  6. set_cart_contents_weight(0);
  7. }
  8.  
  9. <td data-title="Transport Costs">
  10. <ul id="shipping_method">
  11. <li>
  12. <input type="radio" name="shipping_method[0]" data-index="0" id="shipping_method_0_wbs10065ab3a2_delivery" value="wbs:10:065ab3a2_delivery" class="shipping_method" checked='checked' />
  13. <label for="shipping_method_0_wbs10065ab3a2_delivery">Delivery: <span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">&#36;</span>6.28</span></label>
  14. </li>
  15. <li>
  16. <input type="radio" name="shipping_method[0]" data-index="0" id="shipping_method_0_local_pickup16" value="local_pickup:16" class="shipping_method" />
  17. <label for="shipping_method_0_local_pickup16">Local pickup</label>
  18. </li>
  19. </ul>
  20.  
  21. add_filter( 'woocommerce_cart_needs_shipping', 'show_hide_shipping_methods' );
  22. function show_hide_shipping_methods( $needs_shipping ) {
  23. $cart_items_total = WC()->cart->get_cart_contents_total();
  24.  
  25. if ( $cart_items_total < 40 ) {
  26. $needs_shipping = false;
  27.  
  28. // Optional: Enable shipping address form
  29. add_filter('woocommerce_cart_needs_shipping_address', '__return_true' );
  30. }
  31.  
  32. return $needs_shipping;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement