Skip to content

Change a layer with rules

A rule changes a layer when the data of a product meets a condition. Use rules to show a badge only on discounted products, or to give the band a brand’s colour. Rules live in the Conditional Properties section of the Data Settings tab, below the data mapping of the layer.

A rule has two parts:

  • An if row: a product field and a test on it, for example brand and text equal.
  • One or more actions, each with its own value: what happens to this layer when the test is met.

The Conditional Properties section of the band layer: the field brand, the rule text equal, the value Kestro and the action Change Fill Color with the colour #0f9d58

  1. Select the layer and open Data Settings.
  2. Click the plus button next to Conditional Properties. Once the layer has a rule, it becomes a “…” button with Add Next Condition, and the same button also appears under the rules.
  3. Fill in the rule, as described below.
  4. To add another action to the same rule, click Add Action.

A layer can have up to 20 rules. To remove one, click Remove on its if row.

The left box of the if row is the field. It has a search box (Search Field) and these groups:

  • Smart Conditions: Item is discounted and Item is not discounted. They need no rule and no value: pick one and the row is complete. Cropink decides whether an item is discounted from its price and sale price.
  • Common Fields: the fields most layers use, such as title, current_price and image_link.
  • Then the other fields of your products, grouped by type.

The right box is the rule. What it offers depends on the type of the field. Cropink takes the type from its own list of fields:

Field type Fields, for example Rules
Text title, brand, product_type, color is empty, is not empty, contains, not contains, text equal, text not equal
Number sale_price, current_price, discount_percentage is empty, is not empty, number greater than, number less than
Text and number custom_label_0 to custom_label_4 the text rules and the two number rules
Image image_link, additional_image_link_0 is empty, is not empty, contains, not contains
List of tags internal_labels is empty, is not empty, is equal any, is not equal any

Fields that are Cropink’s own versions of a text, number or image field (such as cropink_label_0) follow the type they copy. A field of any other kind gets only is empty and is not empty. If you change the field to one of another type, Cropink clears a rule that no longer fits.

For every rule except the empty tests, a value box appears under the row. It is required.

  • Text rules take text, for example Kestro. The box says Text.
  • number greater than and number less than take a number, for example 100. The box says Number. Use digits, with a comma or a dot for decimals. Letters and symbols are dropped as you type (not on a field that is both text and number), and a minus sign is not accepted, so a rule cannot compare with a negative number.
  • is equal any and is not equal any take tags (Tag). Press Enter or click away to add a tag; Backspace in an empty box removes the last one; pasted text splits at commas.

Under the if row, each action row has a select (Search Action) and, for most actions, a value. When the test is met, Cropink applies the actions to this layer.

Action Value Layers
Show none all except the main frame
Hide none all except the main frame
Change Fill Color a colour all
Change Border Color a colour all
Map To a product field, picked as in the main data mapping all
Change Text a text text layers
Change Font a font text layers
Change Font Size a size in px, above 0 text layers
Change Placeholder an image from your team’s library image layers (a logo is one)
AI Background Remove Remove or Keep image layers, on some accounts (see below)

“All” means frames, rectangles, images, text and the main frame. A rule can recolour a band or a badge as well as a text. Cropink decides which actions each type of layer may have, so the list on your layer can be shorter than this one.

Three things to know:

  • Each action can be used once in a rule. An action that a row already uses is missing from the other rows, and Add Action disappears when every action is taken. To use the same action twice, for example two colours, make two rules.
  • A layer that is mapped to data cannot use Change Text. If you map the layer later, its Change Text actions are removed.
  • The main frame, the frame that holds the whole design, can be recoloured but cannot be shown or hidden.

To map a layer to a product field, see Map layers to product data.

On an image layer, AI Background Remove removes or keeps the background of the product photo when the test is met. Its value is a switch: Remove (the start value) or Keep. For example, remove the background only for the products of one category.

It is not available on every account. If your list of actions does not have it, your account does not. A design that already has this action keeps it, and its row is locked: it reads This action isn't available on your account. It stays as it is. You can still remove the row. The result does not show on the canvas or in Data Preview. You see it in the images Cropink generates. For the layer-wide switch, see Colours, gradients and images.

Cropink does not check rules in the editor. It sends your rules, in the order they have in the panel, with the product to its server and gets back which ones are met.

If two rules can be met at once and both set the same thing on the layer, for example two fill colours, the editor does not say which one wins. Cropink’s server decides. Write rules that exclude each other, such as Item is discounted and Item is not discounted, or brand equal to different brands.

In this design the badge2Box layer, a “Free returns” badge, is hidden. A rule shows it when the item is discounted.

  1. Select badge2Box and open Data Settings.
  2. Click the plus button next to Conditional Properties.
  3. In the if row, open the field box and choose Item is discounted under Smart Conditions. There is no rule box and no value: the row is complete.
  4. In the action row, choose Show.

Check it in Data Preview. Preview NW-2421, which is discounted, and click badge2Box in the Data Responsive Layers list. Output shows the rule as a sentence with Condition met, and the badge is on the design. Preview NW-2400, which is not discounted: Condition not met and the badge is hidden.

The property rows in Output, such as the one for visibility, show the settings you gave the layer in the editor, not the result of the rule. Here that row says No even while the rule is met. Trust the Condition met or Condition not met badge and the design.

To hide a layer when there is no discount, use Item is not discounted with Hide.

The blue band frame should change colour for products of the brand Kestro.

  1. Select band and open Data Settings.
  2. Add a rule. In the field box, search for brand and pick it.
  3. In the rule box, choose text equal.
  4. In the value box, type Kestro.
  5. In the action row, choose Change Fill Color. Type a hex colour, for example 0F9D58, in the colour box and press Enter. The box shows #0f9d58 and a green swatch. Click the swatch to open the colour picker instead.

Then check the rule in Data Preview. Preview NW-2435, “Kestro Pulse Bluetooth Speaker”: the band is green. Preview NW-2421, “Stridon Court Runner Sneakers”: it stays blue. Both steps are in Test your conditions against data.

  • On the Properties canvas, rules do nothing. It shows the design with placeholder data, so the badge and the band look as you drew them.
  • In Data Preview, the design shows Show and Hide, and the fill and border colours that rules set, for the product you chose. Click the layer in the Data Responsive Layers list: Output lists each rule as Condition met or Condition not met.
  • Other actions (Change Font and Change Font Size among them) show only in Output and in the images Cropink generates for your feed, not on the preview.

A rule has to be complete before you publish: a field, a rule and, where the rule needs one, a value, and every action needs its value (a colour, a text, a font, an image, a size above 0). When you click Review & Publish and a rule is not complete, the editor does not open the review. It selects the first layer with such a rule, opens Data Settings and outlines the empty rule and action boxes in red. No message or window appears.

  1. Fill in the red boxes, or click the minus button on the rule to delete it.
  2. Click Review & Publish again.

The review step lists each rule as a sentence, so you can read it once more before you publish.