Converting scripts to Checkout Extensibility

Converting scripts to Checkout Extensibility

Schmidtc63
Shopify Partner
100 14 27

We are in the process of converting from checkout.liquid to checkout extensibility. We have two scripts we need to convert. The first displays payment gateways depending on the currency. The second displays shipping options based on currency and shipping address.

 

I'm just trying to get a jumpstart on all this. If anyone has examples of what they've done and you're willing to share, we'd really appreciate it.

 

Here are the two scripts:

 

Payment Gateway display:

 

currency = Input.cart.presentment_currency
customer = Input.cart.customer
is_staff_customer = false
is_pr_customer = false

if customer
  if customer.tags.include?('staff_offline_payment')
    is_staff_customer = true
  end
  if customer.tags.include?('cust_pricing_group:PR Group') || customer.tags.include?('cust_pricing_group:Lotus Dots PR')
    is_pr_customer = true
  end
end
if currency == "CAD"
  Output.payment_gateways =
    Input.payment_gateways.delete_if do |payment_gateway|
      payment_gateway.name != "OpenPath Payments" ||
      payment_gateway.name == "Shopify Payments" ||
      payment_gateway.name == "OrderTransfer" ||
      payment_gateway.name == "Shop Pay Installments" ||
      payment_gateway.name == "Afterpay" ||
      payment_gateway.name == "PayPal Express Checkout" ||
      (payment_gateway.name == "KicKee Staff" && !is_staff_customer) ||
      (payment_gateway.name == "PR Group" && !is_pr_customer)
  end
end
if currency == "USD"
  Output.payment_gateways =
    Input.payment_gateways.delete_if do |payment_gateway|
      payment_gateway.name == "OpenPath Payments" ||
      payment_gateway.name == "OrderTransfer" ||
      payment_gateway.name == "Invoice Me" ||
      (payment_gateway.name == "KicKee Staff" && !is_staff_customer) || 
      (payment_gateway.name == "PR Group" && !is_pr_customer)
  end
end

Shipping rates Display:

currency = Input.cart.presentment_currency.upcase
customer = Input.cart.customer
can_willcall = false
hide_Flat = false
province_codes = ["AK", "AS", "FM", "GU", "HI", "MH", "MP", "PW", "PR", "VI", "AA", "AE", "AP"]
address = Input.cart.shipping_address
location = Input.locale.to_s.downcase
isCanada=false

if location.include?('ca')
    isCanada=true
end
if customer
  if customer.tags.include?('staff_offline_payment') || customer.tags.include?('cust_pricing_group:PR Group') || customer.tags.include?('cust_pricing_group:Lotus Dots PR')
    can_willcall = true
  end
end

if address.country_code!=nil && address.country_code.upcase=="US" && (province_codes.include?address.province_code.upcase)
  hide_Flat = true
end

if address.country_code!=nil && address.country_code.upcase=="CA" && currency=="USD"
	hide_Flat = true
end

Output.shipping_rates = Input.shipping_rates.delete_if do |shipping_rate|
  (shipping_rate.name.upcase!="FLAT RATE" && currency == "CAD" && isCanada) ||
  (shipping_rate.name.upcase=="FLAT RATE" && currency != "CAD") ||
  (shipping_rate.name.upcase=="FLAT RATE" && !isCanada) ||
  (shipping_rate.name.upcase=="WILLCALL" &&  !can_willcall) ||
  (shipping_rate.name.upcase=="WAREHOUSE PICKUP" &&  !can_willcall)||
  (shipping_rate.name.upcase=="$5.00 FLAT RATE (CONTINENTAL UNITED STATES ONLY)" && (hide_Flat || currency=="CAD"))
end
Replies 3 (3)

cwveysey
Shopify Partner
7 0 2

Schmidtc63 did you find a solution here? Confirmed that we are looking to do the same for an AfterPay script ("We have two scripts we need to convert. The first displays payment gateways depending on the currency")

Schmidtc63
Shopify Partner
100 14 27

Not yet...hopefully, soon.

cwveysey
Shopify Partner
7 0 2

We used www.checkoutblocks.com to facilitate our desired UX here. Confirmed that I have spoken with Gil from checkoutblocks.com a few times now, and that I think real highly of him and the service.

 

If you wind up signing up and checkoutblocks.com solves your problem, let Gil know that Cooper from Form Factory sent you his way 😉