For COD disable for a collection of products with tag, up to the amount and certain Pincode – Shopify Script

0 Shares
0
0
0

Shopify script only supported for SHOPIFY PLUS and SHOPIFY GOLD Account. It will not work for Basic / Shopify or Advance version

For COD disable for a collection of products with tag, up to the amount and certain Pincode for e.g You have products for MAN and WOMAN. You want to activate COD only for certain Pincode for MAN and up to Rs: 10000. for WOMAN you want to activate COD up to Rs: 5000.

Please ADD Tag respectively for products.

You have activated COD for Payments

[ruby]
allow_product_tag_cod = false
allow_cod = true
has_products_tag = Input.cart.line_items.any? { |line_item| line_item.variant.product.tags.include?('MAN') }
deletecod_button = true
PINCODE_ALLOW_COD = [
  '400001','400002','400003','400004','400005'
]
if has_products_tag
  min_discount_order_amount = Money.new(cents:100) * 10000 # For MAN - Amount limit upto 10000
  if Input.cart.shipping_address and PINCODE_ALLOW_COD.include?(Input.cart.shipping_address.zip) and min_discount_order_amount > Input.cart.subtotal_price_was
    deletecod_button = false
  else
    deletecod_button = true
  end
else
  min_discount_order_amount = Money.new(cents:100) * 5000 # For Other / WOMAN - Amount limit upto 5000
  if min_discount_order_amount > Input.cart.subtotal_price_was
    deletecod_button = false
  end
end
if deletecod_button == true
   Output.payment_gateways = Input.payment_gateways.delete_if { |payment_gateway| payment_gateway.name.include?("COD") }
 else
   Output.payment_gateways = Input.payment_gateways
end
[ruby]

if you have any query please mail me at tejashweta@gmail.com