Cashier Scripts Code Library

Follow

Warning!

This feature is currently in a beta access state. Please contact our Merchant Success team to get access.

Overview

Cashier Scripts is a plugin for Bold Cashier that allows you to further customize your checkout. With Cashier Scripts, you're able to:

  • Discount your customer's order
  • Add order fees
  • Include additional products
  • Place different types of widgets in the checkout
  • Offer automatic discounts
  • Add site trust badges
  • Create a pop-up for your return policy, and so much more.

Please visit Cashier Scripts Set-up Information & FAQs for more information on Cashier Scripts and how to set up this plugin.

Select each of the sections below to view some examples and additional information:

addFee(id, text, type, amount, taxable);
  • id - A unique identifier that you will create for the fee.
  • text - What will appear beside the price of the fee in the checkout, as well as on the order in Shopify.
  • type - Choose fixed or percentage.
  • amount - Dollar amount or percentage to add.
  • taxable - True or false, whether the fee is taxable.

Below are some coding examples of fees and how they display in Cashier's checkout:

Fixed Fee - Not Taxable

addFee(123, "Service Fee", "fixed", "2.50", false);

Example of adding a fixed fee using Cashier Scripts

Percentage Fee - Taxable

addFee(123, "Handling Fee", "percentage", "7.5", true);

Example of adding a percentage fee using Cashier Scripts

Multiple Fees

addFee(123, "Eco Fee", "percentage", "2.8", false);
addFee(456, "Online Processing Fee", "fixed", "4.5", false);

Example of adding multiple fees using Cashier Scripts

Additional Information:

  • The fees will be added as a separate line item in the Shopify order.
  • You can use conditional logic to add fees under specific circumstances.
addLineItem({
  platform_variant_id: 1234567890,
  line_item_key: "",
  quantity: 1,
  properties: {
  name: 'value'
  },
  price: 1234
});
  • platform_variant_id - Shopify’s variant ID.
  • line_item_key - A unique identifier for your line item (optional).
  • quantity - Quantity of the line item to add - defaults to 1 (optional).
  • properties - Add properties to your product (optional).
  • price - Price for the product in cents - defaults to original product price (optional).

Here's an example:

addLineItem({
  platform_variant_id: 15419996012579,
  line_item_key: "",
  quantity: 1,
  properties: {
    note: 'Free Gift'
  },
  price: 0
});

Example of adding a line item with Cashier Scripts

Example of adding a line item with Cashier Scripts

Additional Information:

  • You will not be able to see the properties added at checkout. They will be on the order in Shopify.
  • You can add multiple line items to the order.
  • You can use conditional logic to add a line item under specific circumstances.
discountCartByPercent(amount, text);
  • amount - Percentage amount.
  • text - Text that displays beside the discount.

Here is an example:

discountCartByPercent(20, "20% discount");

Example of discounting the order using Cashier Scripts

You can also add multiple discounts to a customer's cart:

discountCartByPercent(25, "Black Friday Site Wide Discount!");
discountCartByPercent(10, "Clearence Sale");

Example of adding two discounts using Cashier Scripts

Additional Information:

  • You can use conditional logic to add discounts under specific circumstances.
  • A discount is based off of the subtotal; before any other discounts are applied.
cart.line_items.forEach(function(item){
  item.changeLinePrice(amount);
});
  • amount - The price to set the line items to, in cents. A calculation could also be used.

Set to a Specific Price - Every Line Item

cart.line_items.forEach(function(item){
  item.changeLinePrice(1000);
});

Example of changing the line item price to a fixed price

Use a Calculation - Every Item

cart.line_items.forEach(function(item){
  item.changeLinePrice(item.price * 0.75);
});

or

cart.line_items.forEach(function(item){
  item.changeLinePrice(item.price - (item.price * 0.25));
});

Example of changing the line item price by a percent

Set a Specific Line Item's Price

cart.line_items.forEach(function(item){
  if (item.platform_variant_id == 15419997028387 ){
  item.changeLinePrice(item.price - (item.price * 0.33));
}
});

Example of changing a specific line item's price

Additional Information:

  • This code sets the item price. The checkout or order won't show that the item's price has been changed.
  • You can use conditional logic to set the price under specific circumstances.
if (customer.core_info.tags.indexOf("tag")>-1) {
  addShippingOverride('Script Name');
}
  • tag - The tag that qualifies for these shipping rates.
  • Script Name - The name of the script that will set the shipping rates.
addShippingLine("name", amount);
  • name - The name that shows up on the shipping line.
  • amount - The amount of the shipping rate.

Example:

Add this script into the initialize script:

if (customer.core_info.tags.indexOf("vip")>-1) {
  addShippingOverride('VIP Shipping');
}

Create a new script under Shipping, call it VIP Shipping, and add the following script:

addShippingLine("VIP Shipping - 1-2 days", 15);
addShippingLine("VIP Shipping - 3-7 days", 5);
addShippingLine("VIP Shipping - 1-2 weeks", 2);
addShippingLine("VIP Shipping - 3+ weeks", 0);

Example of a shipping rate override

An iframe widget allows you to use HTML and CSS to create a widget on the checkout page. This can be used to add an image, trust badges, text, and more.

addIframeWidget('name', {
  position: 'position'
  source: 'https://domain.com/iframe-widget'
  frame-origin: 'https://domain.com'
});
  • name - The name of the widget. This needs to be the same as the name of the widget script.
  • position - Sets the position of the widget.
  • source - The source of the iframe. If the source is not set, it will use the name argument (optional).
  • frame-origin - If defining the source, you will need to set this with the domain. (optional)

Add Trust Badges to the Checkout:

Add this code to the initialize script:

addIframeWidget('Trust Badges', {
  position: 'payments'
});

Add the following code to a widget script titled Trust Badges:

Note: Your image files will need to be hosted somewhere. We suggest using the "Files" section of your Shopify admin.

Please visit our IFrame Widget Code Template for a basic coding example.

Example of an iframe widget

An external link widget allows you to add a link to page outside of your checkout.

Note: For external link widgets, you do not need to create a corresponding widget script.

addExternalLinkWidget('name', {
  position: 'position',
  text: "test",
  icon: "https://url.com/icon.png",
  url: "https://yourstore.myshopify.com/pages/refund-policy"
});
  • name - The name of the widget. 
  • position - Sets the position of the widget.
  • text - Text that shows up in the widget.
  • icon - Icon that shows up in the widget (optional).
  • url - Link that customer gets redirected to.

Link to a Refund Policy Page

Add this code to the initialize script:

addExternalLinkWidget('refund', {
  position: 'summary_above_header',
  text: "Check our refund policy",
  icon: "https://url.com/icon.png",
  url: "https://yourstore.myshopify.com/pages/refund-policy"
});

Example of an external link widget

A modal widget allows you to use HTML and CSS to create a pop-up that appears when your customer clicks the widget.

This can be used to add some information, images or anything else, in a popup.

addModalWidget('name', {
	position: 'position',
	text: 'Text',
	icon: 'https://url.com/icon.png', 
        click_url: 'https://url.com/modal.html',
        frame_origin: 'https://url.com',
  });
  • name - The name of the widget. This needs to be the same as the name of the widget script.
  • position - Sets the position of the widget.
  • text - Text that shows up in the widget.
  • icon - Icon that shows up in the widget (optional).
  • click_url - The source of the modal. If the source is not set, it will use the name argument (optional).
  • frame-origin - If defining the source, you will need to set this with the domain (optional).

Add Shipping Information to a Modal

Add this script to the initialize script:

addModalWidget('International Shipping', {
	position: 'customer_info',
	text: 'Click here to see our International Shipping policy',
	icon: 'https://url.com/icon.png',
});

Add the following code to a widget script titled International Shipping:

Note: Your image files will need to be hosted somewhere. We suggest using the "Files" section of your Shopify admin.

Please visit our Modal Widget Code Template for a basic coding example.

Example of a modal widget

Modal that shows up when clicking the modal widget

1 out of 1 found this helpful

Comments

0 comments

Please sign in to leave a comment.