Code Snippets Overview

Ablestar Bulk Product Editor allows you to use custom Liquid code to modify your product data. For example, the following code would set a product status to 'Active' if vendor metadata equaled "Ablestar":

{% if product.vendor == "Ablestar" %}
 {% assign product.status = "active" %}
{% endif %}

Code snippets are a new feature that we are still fine-tuning. Please test the code carefully before applying it to your products.

As with other edits, you can always undo the modifications made to your products. If you run into any difficulties creating a code snippet please get in touch so we can help!

Watch our Code Snippet demo to see how you can create and use code snippets.

Advantages of Code Snippets

Code snippets allow you to implement custom logic on your product data using Liquid code. The possibilities are almost endless. Here are a few examples we have seen store owners use successfully:

  • Set Metafields: you can set the value of metafields, to reflect the properties of various product tags
  • Google Shopping: Automatically set Google Shopping fields using the values of other fields
  • Product Status: Manage a product lifecycle, moving the product between 'Draft', 'Active' and 'Archived' states depending on inventory levels, images and price
  • Dynamic Cost: Set the cost of a product based on which vendor metadata is present

Creating and Editing Code Snippets

Create New

You have to create code snippets before they can be applied in the app.

From the dashboard, click the 'Settings' menu and choose the Code snippets section.

From the 'Code snippets' view, you will see a list of existing code snippets. Click the Create code snippet button to continue.

See more Example Code Snippets in this article.

Edit Existing

From the 'Code snippets' view, you will see a list of existing and historical code snippets. Clicking on any row will redirect you to the full detail of the snippet for editing, where you have some options:

  • Preview edit: While editing a code snippet you can click to preview the changes on any product, to confirm changes before making changes to the product. Click the 'Preview Product → Select Store link to choose your product.
  • Debugging: To help with debugging you should configure your Liquid code output as {{ product.vendor }} and the output will appear for preview.

After saving a code snippet, you will be able to find and configure them in the next steps.

Code snippet modifications will automatically be applied to all upcoming product updates.

Apply Code Snippets

Once you have created your code snippets, you can run the code snippets against your products using two methods, either as a one-time edit or a recurring edit:

  1. In-App Edit: allows a one-time edit from the Product search area. Once products are filtered and ready to edit on the 'Configure modifications' view, searchcode on the 'Field to edit' dropdown:

  1. Automations: allows a recurring edit on the code snippet.

Click 'Automations → Product rules → Create a rule' from the navigation menu and then search code from the 'Field to edit' dropdown to find all code snippets created:

When creating recurring product rules with code snippets we recommend you only have a single code snippet for the product rule and include all your logic in that one snippet.

Liquid Support in Code Snippets

Code snippets support all core Liquid syntax. A product variable is available to the Liquid code and modifications to that product will synced with Shopify.

The product variable is similar to the variable available when editing themes but we have added additional fields and still need to implement some Shopify-specific fields. While editing a code snippet to preview against a product, the preview will show you all the data available for that product.

If you come across a missing field that you need, please let us know.

Differences Between Code Snippets and Standard Liquid

In order to support editing product data from Liquid code we've made several extensions to the Liquid language. There are also some lesser-used field on the main product object that we are still working on implementing.

✅ Tips and Troubleshooting

(06.222)

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us