using "current time" in Shopify Scripts

Highlighted
New Member
3 0 0

Hello,
I have a current shipping script that deletes specific shipping methods based on some IF rules. 

I have just added a new "SAME DAY" shipping method but I want it to be available only between 12AM-12PM.
So, I'm trying to add a new rule to the script, that checks the current hour.
The problem is I'm not sure how to "call" the current time in Ruby?
I guess the code should look something like this:

n = Time.now
if n.hour  > 12
  Input.shipping_rates.delete_if do |shipping_rate|
    shipping_rate.name.upcase.include?("SAME  DAY")
    end 
end

Any ideas?

Thanks!
Lior

0 Likes
Highlighted
Shopify Expert
9925 103 1763

Time isn't available in Shopify Scripts so you won't be able to make use of it directly. 

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
1 Like
Highlighted
New Member
3 0 0

thanks Jason!

0 Likes
Highlighted
Shopify Partner
5 0 0

Hello,

 

Is there any other way available to get the current time in Shopify scripts?

 

Thanks

0 Likes
Highlighted
Shopify Expert
9925 103 1763

@sohail4 wrote:

Hello,

 

Is there any other way available to get the current time in Shopify scripts?

 

Thanks


No. Time functions are not supported. Whatever you're trying to achieve will need to be handled in a different way.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes