Title Replies Last Post
Introducing Shopify Scripts: Customize the business logic of your Shopif...

Shopify's Script Editor allows you to create Ruby scripts that can change the prices and properties of line items in your store's cart. Using scripts, you can create discounts that will be applied automatically based on the items and properties of a cart. The Script Editor app adds a place to write and store scripts in your Shopify admin. This forum is for questions and discussion surroundin...

15
Dec 10 2017 by Jason
Shopify Scripts: Read before posting

This category in the forums is dedicated to the Shopify Script Editor. Please ensure your question relates to the Scripts API or the Script Editor app. Documentation: Shopify Scripts API Shopify Script Editor app App store: Script Editor If you have general API questions unlrelated to Shopify Scripts post in the Shopify APIs & SDKs category. If your question is about storefront ...

0
Feb 7 2017 by Jason
Recognize JS cookie in shipping script

I am using Monetate (AB platform) to test free shipping on orders over $75 (50/50 traffic split). If a session is in the experiment group, Monetate creates a JS cookie. Is it possible for a Shopify shipping script to recgonize the presence of that JS cookie value? If so, i want to append that code to this existing prefab script for free UPS ground shipping on orders over $75 -    MIN...

5
Today by Nikolas Alexander
Hide/open price for customers

Hello! I use this code to hide prices for unregistered guests: {% if customer %} <span class="money">{{ product.price | money }}</span> {% endif %} But in <script  type="text/x-jquery-tmpl"> it does not work. Prompt how correctly to insert a condition in the code. <script id="paira-compare-template" type="text/x-jquery-tmpl"> <tr class="paira-...

1
Yesterday by Kostya Kulik
Variable on checkout confirmation page to determine if user is logged in...

While you can use the customer object to determine if a user is logged in or not anywhere on the site, this seems to always return true on the checkout confirmation page when this is used inside Admin > Checkuot > Order Processing > Additional Scripts (even when purchasing through guest checkout when user is not logged in).   {% if customer %} https://help.shopify.com/themes/li...

0
Dec 11 2017 by mike
Setting price of product as a % of cart

I'm looking for a more elegant solution to set the price of a product based on a percentage of cart $ size. Here's what I have working so far.  In this Shopify Plus store, https://www.bullets2bandages.org/cart/add?id=19593494467, we have a Rush upsell in the cart.  The upsell snippet in the cart adds the Rush Order Upgrade product to the cart.  Then the cart script sets the price for the Rus...

0
Dec 11 2017 by Scott Austin
imagesLoaded is not a function

Hello community, I have an issue that when I'm on the product page and click the thumbnail images they don't show up and I get this error on the console: Uncaught TypeError: photos.find(...).eq(...).delay(...).imagesLoaded is not a function     at ProductPage.updateActiveImg (theme.js?1006191…:3896)     at ProductPage.updateActiveImg (theme.js?1006191…:77)     at HTMLLIElement.<anon...

0
Dec 8 2017 by freittas
Script - Percentage discount on items with tag, if you have over 100 dol...

Good Morning from Texas. I am trying to set up a script on my store that gives a percentage discount on items with a tag, if you have over 100 dollars worth of items with that tag in the cart.  I've set up a few scripts successfully before, but this one is a doozie. Granted I don't know much Ruby, I am a front end web developer. Any assistance would be greatly appreciated!

1
Dec 8 2017 by rickydazla
Make script run only once

Hi, I wrote this script to discount $69 off any product with a black friday tag. I want the script to only give the discount ONCE. Right now, if you add a black friday product, it'll give you the discount, and then give you the discount again if you add another BF product.   min_discount_order_amount = Money.new(cents:100) * 219 #minimum amount needed to have in cart to get discount to...

3
Nov 22 2017 by Nikolas Alexander
Unknown error on Shopify Scripts app

I'm trying to apply a fixed-amount discount to a cart that is over a certain amount, and I think I finally figured out the correct way to edit the cart subtotal. The issue is, I'm getting an error that I don't understand when I'm running the script. Here's the code: class AmountsDiscountCampaign def initialize(cart1, discount1, cart2, discount2) @cart1 = Money.new(cents:100) * ...

1
Nov 20 2017 by rickydazla
Shopify Scripts amount off total.

I've been trying to find a Shopify script that simply removes a set amount from `Input.cart.subtotal_price`. Every one I've come across seems to remove the set amount from each line item, which doesn't really make a whole lot of sense. For example - https://gist.github.com/dylanjhunt/a0e4352d9f69174b46ef2962574cd7f6 Is this even possible? The only "change" item I see on the API page is .chan...

3
Nov 19 2017 by Chris Gerringer
Undefined method for main object - script for checking shipping address

Using Fulfillment by Amazon we have to limit PO Box addresses to Standard Shipping only. Script flow get address1 as upcase string set to "addressline1" variable build array of "PO Box" permutations (i.e. P.O. BOX, P.O.BOX, ...) if array contains address1 hide shipping options else return all I'm getting an error in the if check though "undefined method 'addressline1' for ma...

6
Nov 13 2017 by a-aron
regex

is it possible to use regexes to extract data from a tag? I want to get the trailing number from a tag to use as part of logic. what I wanted to do was puts "blah_blah_24"[/\d+$/] my hacky work-around is puts "blah_blah_24".reverse.to_i.to_s.reverse.to_i the error I get when trying to use regex is [Error] uninitialized constant Regex

1
Nov 9 2017 by jeremy
puts not outputting to console

I can't get puts to work. What am I doing wrong here? https://help.shopify.com/manual/apps/apps-by-shopify/script-editor/limitations   Input.cart.line_items.each do |item|   product = item.variant.product      puts product.id    end Output.cart = Input.cart

1
Nov 7 2017 by jeremy
Script editor: line items scripts - get product collection

I need to implement a logic, where customer gets discount if he byes X or more items from the same collection Thried to do it using line item script from shopify plus functionality, but wasn't able to find the approipriate product data in the line_items collection Coldn't find anything about product collections in shopify scripts documentation https://help.shopify.com/api/tutorials/shopif...

2
Nov 4 2017 by Alex
Using the api for shiping options

I need to allow free shiping based on some very specific needs using a shipping code: Free ground/standard shipping with FedEx/USPS Does not apply to overnight, 2 day, etc. Does not apply to sale items Without the code the user can do $7.95 flat rate ground I don't quite understand ho to use the shipping API to make this work. Can anyone give me a high level view on how to go a...

4
Nov 2 2017 by David
How to access Discount Codes

Simple cart with a discount code is selected. Try to run a simple script.  cart = Input.cart dc = cart.discount_code puts "DC: #{dc}" Output.cart = Input.cart Generates an error:  Code requirements not met What am I missing? Why is script editor choking on this simple test? The Code itself is just 50% of products in the cart.  Would be nice if the error messages inc...

3
Oct 25 2017 by HunkyBill
Discount code requirements not met error

I'm working on a script that applies free shipping on specific shipping methods if the code "FREESHIP" is used. When I try to write this script I get an error that says:   Discount code requirements not met (Your cart) Discount code requirements not met (Empty cart) Discount code requirements not met (No customer) The code I'm using: Input.shipping_rates.each do |shipping_ra...

0
Oct 24 2017 by David
Message on cart page

Hi, First of all I want to say I've been looking around for hours and didn't find an answer for this question so.... here I am. I've been playing with shopify plus script editor and I've made it work for a "Buy 2 get 1 free" offer. Everything is fine except: - the message appears only if the condition is already met That is the problem, I want to be able to tell display a message "a...

0
Oct 18 2017 by VRuler
using "current time" in Shopify Scripts

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 someth...

2
Oct 18 2017 by Lior L