> For the complete documentation index, see [llms.txt](https://docs.rishvi.co.uk/linnworks/llms.txt).
> Use it to discover all available pages before exploring further.

# Reduce Item’s Discount

Automatically update discounts on zero-value Linnworks order items and rebalance the recovered value against an eligible paid item on the same order.

Managing zero-value order items manually can be time-consuming and increases the risk of inconsistent pricing adjustments across order lines. The *Automated Discount Rebalancing for Zero-Value Order Items* macro helps identify selected orders that contain items with zero or negative value and updates their discount using a configured discount value.

This solution checks each selected Linnworks order, finds order items where **CostIncTax** is less than or equal to zero and the item discount is **100**, changes the item discount to the configured value, marks the item as changed, and then offsets the recovered value against an eligible paid item on the same order.

With this automated approach, your team can handle zero-value order items more consistently, reduce manual order edits, and keep an item-level marker showing that the zero-value item has already been adjusted.

> Automatically adjust zero-value order items and rebalance the related discount value against a paid item in the same order.

## **Configure the Macro**

Once the app is installed, you need to set up the configuration, so the system knows which orders to review and what discount value to apply to eligible zero-value items. This is a one-time setup and can be adjusted anytime based on your operational needs.

### **Steps to Configure**

<Tabs>
  <Tab title="Step 1">
    **Go to Apps > Macro Configuration and click + Add new configuration.**

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779094211819-m4d4f11jrx-pasted-image-1779094207771.png?fm=auto&auto=compress%2Cformat" width="1368" height="568" alt="" priority={true} fetchPriority="high" />
  </Tab>

  <Tab title="Step 2">
    **Select the Reduce Item Discount macro and click Create Configuration**

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779184212020-lywh5ctq6c-pasted-image-1779184208709.png?fm=auto&auto=compress%2Cformat" width="1029" height="458" alt="" priority={true} fetchPriority="high" />

    This creates a new configuration where you can define the schedule and required parameter values.
  </Tab>

  <Tab title="Step 3">
    **In the Macro Configuration screen, add the configuration name and parameter values.**

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779184251435-dksuh9vtbnr-pasted-image-1779184248738.png?fm=auto&auto=compress%2Cformat" width="672" height="515" alt="" style="width: 672px; height: auto; cursor: pointer; margin: 0 auto;" />

    - Enter or update the **discountValue** value in the **Value** column
  </Tab>

  <Tab title="Step 4">
    **Make sure to enable the macro to continue with the Rule Engine configuration.**

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779184372820-ko3alc2htbd-pasted-image-1779184368921.png?fm=auto&auto=compress%2Cformat" width="1494" height="28" alt="" />

    <Callout kind="warning" collapsed="false">
      **Note:** If the macro is not enabled, it will not appear in the **Action** value list when setting up the rule.
    </Callout>
  </Tab>

  <Tab title="Step 5">
    **Go to Orders > Rules engine and click + Add new rule.**

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779094587683-vdcfps4fxa-pasted-image-1779094584371.png?fm=auto&auto=compress%2Cformat" width="1369" height="606" alt="" />

    **Key Benefits**
  </Tab>

  <Tab title="Step 6">
    **Enter the rule name and click Create.**

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779184450668-anat51ttplo-pasted-image-1779184447972.png?fm=auto&auto=compress%2Cformat" width="302" height="182" alt="" style="width: 302px; height: auto; cursor: pointer; margin: 0 auto;" />
  </Tab>

  <Tab title="Step 7">
    **Click Add new, select Condition, set the condition as required, and save it.**

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779099941621-j5whfpzeq2-pasted-image-1779099937975.png?fm=auto&auto=compress%2Cformat" width="468" height="109" alt="" style="width: 468px; height: auto; cursor: pointer; margin: 0 auto;" />

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779184565695-ibj40i3iihm-pasted-image-1779184562969.png?fm=auto&auto=compress%2Cformat" width="601" height="293" alt="" />
  </Tab>

  <Tab title="Step 8">
   **Add the macro action and click Save.**

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779187386763-44jx4pc5eob-pasted-image-1779187383840.png?fm=auto&auto=compress%2Cformat" width="677" height="155" alt="" style="width: 677px; height: auto; cursor: pointer; margin: 0 auto;" />

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779184626106-xkb7fnq85cd-pasted-image-1779184623416.png?fm=auto&auto=compress%2Cformat" width="614" height="248" alt="" style="width: 614px; height: auto; cursor: pointer; margin: 0 auto;" />

    In the **Add action** window, enter the **Action name**, for example:

    `IfDiscountValueZero`

    - Set **Action type** to:

      `Execute a macro`

    - In **Action value**, select:

      `AddMissingPhoneAndEmail`

    - Click **Save**

    <Callout kind="warning" collapsed="false">
      **Note:** If the macro is not enabled, it will not appear in the **Action** value list when setting up the rule.
    </Callout>
  </Tab>

  <Tab title="Step 9">
    **Review the saved rule setup.**

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779184714290-192j3mj5ww6-pasted-image-1779184711333.png?fm=auto&auto=compress%2Cformat" width="1533" height="703" alt="" />

    - Verify the condition and action are connected correctly

    - Click **Save** in the bottom-right corner to save the rule
  </Tab>
</Tabs>

## **Key Benefits**

Correcting zero-value order lines manually requires checking item prices, discount values, and related paid items. This macro is designed to automate that process while marking adjusted items to avoid repeat item-level changes.

<Columns cols="2">
  <Card title="Find Zero-Value Items" icon="alarm-check" horizontal="false" target="_self">
    Reviews selected orders and identifies items where **CostIncTax** is less than or equal to zero.
  </Card>

  <Card title="Update 100% Discounts" icon="bell" horizontal="false" target="_self">
    Changes eligible items with `Discount = 100` to the configured **discountValue**.
  </Card>

  <Card title="Mark Changed Items" icon="boxes" horizontal="false" target="_self">
    Adds `ItemValueChanged = Yes` to item additional information when the item has not already been marked.
  </Card>

  <Card title="Rebalance Paid Item Value" icon="bar-chart-big-icon" horizontal="false" target="_self">
    Applies the recovered value by reducing the **PricePerUnit** of an eligible paid item on the same order.
  </Card>

  <Card title="Process Selected Orders" icon="lucide-fast-forward" horizontal="false" target="_self">
    Works only on the order IDs supplied to the macro through the **OrderIds** parameter.
  </Card>

  <Card title="Log Macro Activity" icon="lucide-message-circle-x" horizontal="false" target="_self">
    Writes macro start, error, and finish messages to the macro log.
  </Card>
</Columns>

### How It Works

This macro works against the provided list of order IDs. Once it runs, it checks each order for zero-value items and updates only the eligible items that match the macro conditions.

<Steps>
  <Step title="Step 1" icon="airplay-icon" title-type="p">
    The macro starts and writes **Macro started** in the log.
  </Step>

  <Step title="Step 2" icon="airplay-icon" title-type="p">
    It loops through each order ID provided in the **OrderIds** parameter.
  </Step>

  <Step title="Step 3" icon="airplay-icon" title-type="p">
    It retrieves the order details from Linnworks using **GetOrderById**.
  </Step>

  <Step title="Step 4" icon="airplay-icon" title-type="p">
    It checks whether the order contains any item where **CostIncTax** is less than or equal to **0**.
  </Step>

  <Step title="Step 5" icon="airplay-icon" title-type="p">
    For each zero-value item where **Discount** is **100**, the macro changes the item discount to the configured **discountValue**.
  </Step>

  <Step title="Step 6" icon="airplay-icon" title-type="p">
    It updates the order item using **UpdateOrderItem** and adds the updated item cost to the value that needs to be rebalanced.
  </Step>

  <Step title="Step 7" icon="airplay-icon" title-type="p">
    If the item does not already contain **ItemValueChanged**, the macro adds `ItemValueChanged = Yes` to the item additional information.
  </Step>

  <Step title="Step 8" icon="airplay-icon" title-type="p">
    If a rebalance value exists, the macro finds a paid item where **CostIncTax** is greater than **0** and greater than the rebalance value.
  </Step>

  <Step title="Step 9" icon="airplay-icon" title-type="p">
    It reduces that paid item’s **PricePerUnit** by the rebalance value and updates the order item.
  </Step>

  <Step title="Step 10" icon="airplay-icon" title-type="p">
    The macro finishes and writes **Macro Finished** in the log.
  </Step>
</Steps>

### **Usage of App**

This macro is designed to adjust selected Linnworks orders where one or more order items have zero or negative value and a full discount. It should be used when those zero-value items need their discount changed while the related value is offset against another eligible paid item on the same order.

<Card title="OrderIds" horizontal="false" target="_self">
  Defines the list of Linnworks orders that the macro should process. Each order ID is checked individually.
</Card>

<Card title="discountValue" horizontal="false" target="_self">
  Defines the discount value that replaces **100** on eligible zero-value items. For example, if the value is **50**, matching items are updated from `Discount = 100` to `Discount = 50`.
</Card>

<Card title="CostIncTax" horizontal="false" target="_self">
  Used to identify zero-value items. The macro checks for items where **CostIncTax** is less than or equal to **0**.
</Card>

<Card title="Discount" horizontal="false" target="_self">
  The macro only changes zero-value items where the current **Discount** value is **100**.
</Card>

<Card title="ItemValueChanged" horizontal="false" target="_self">
  Added to the item additional information with the value **Yes** after an eligible item is updated.
</Card>

<Card title="PricePerUnit" horizontal="false" target="_self">
  Reduced on one eligible paid item by the total rebalance value calculated from updated zero-value items.
</Card>

### **Key Points to Remember**

- The macro works on the order IDs passed through **OrderIds**

- The **discountValue** parameter controls the new discount applied to eligible zero-value items

- The macro only targets items where `CostIncTax <= 0` and `Discount = 100`

- Updated zero-value items are marked with `ItemValueChanged = Yes`

- The macro totals the updated item cost returned by **UpdateOrderItem**

- If the total rebalance value is greater than **0**, one paid item is selected for price adjustment

- The paid item must have `CostIncTax > 0` and `CostIncTax > addDiscountValue`

- The selected paid item’s **PricePerUnit** is reduced by the calculated rebalance value

- The macro writes errors to the log and always writes **Macro Finished** at the end

Once the macro is running, it helps ensure zero-value item discount adjustments are applied consistently across selected orders.

### **What You Can Expect**

- **Selected orders are reviewed one by one**\
  Each order ID passed to the macro is retrieved and checked before changes are made

- **Only orders with zero-value items are changed**\
  Orders without items where `CostIncTax <= 0` are skipped

- **Only fully discounted zero-value items are updated**\
  The item must have `Discount = 100` before the macro changes it to **discountValue**

- **Changed items are marked**\
  The macro adds `ItemValueChanged = Yes` to item additional information when the marker is not already present

- **A paid item may be reduced**\
  If the macro calculates a rebalance value, it reduces the **PricePerUnit** of the first eligible paid item found

- **Macro completion is logged**\
  The macro writes **Macro Finished** after the run ends

### **Overall Impact**

This helps reduce manual item-level edits, improves consistency when changing discounts for zero-value order lines, and supports controlled rebalancing against paid items on the same order.

### What To Do When an Order Is Not Updated

If an expected order is not updated by the macro, review the order and macro conditions before taking manual action.

### **Steps to Follow**

<Steps>
  <Step title="Step 1" title-type="p">
    Open Linnworks and locate the order that was expected to be updated.
  </Step>

  <Step title="Step 2" title-type="p">
    Confirm that the order ID was included in the **OrderIds** parameter.
  </Step>

  <Step title="Step 3" title-type="p">
    Check whether the order contains at least one item where **CostIncTax** is less than or equal to **0**.
  </Step>

  <Step title="Step 4" title-type="p">
    Confirm that the zero-value item currently has `Discount = 100`.
  </Step>

  <Step title="Step 5" title-type="p">
    Review the item additional information and check whether **ItemValueChanged** already exists.
  </Step>

  <Step title="Step 6" title-type="p">
    If the paid item was not adjusted, confirm there is an item where `CostIncTax > 0` and `CostIncTax > addDiscountValue`.
  </Step>

  <Step title="Step 7" title-type="p">
    Review the macro logs for any exception or processing message.
  </Step>
</Steps>

### **Why This Matters**

Reviewing these conditions helps you understand whether the order was skipped because it did not contain eligible zero-value items, the item was not fully discounted, the item was already marked as changed, no suitable paid item was available, or the macro failed during processing.

### Best Practices

To get the most value from this macro, use it carefully on the correct order set and verify the discount value before running it.

### **Recommended Guidelines**

- **Check the selected orders before running**\
  Confirm that only the intended orders are included in the **OrderIds** list

- **Use a clear discount value**\
  Enter the replacement discount as a numeric value such as **50** for a 50% discount

- **Review zero-value items first**\
  Confirm that the target order items have `CostIncTax <= 0` and `Discount = 100`

- **Confirm a paid item exists**\
  Make sure the order includes a paid item with enough value to absorb the rebalance amount

- **Review item additional information after processing**\
  Check that `ItemValueChanged = Yes` has been added where expected

- **Review updated paid item pricing**\
  Confirm that the selected paid item’s **PricePerUnit** has been reduced correctly

- **Test before production use**\
  Validate the discount and rebalance logic on a small order set before using it at scale

> Review the selected orders and discount value before enabling or running the macro.

### **Example Scenario**

To better understand how this works, here’s a simple example:

If your **discountValue** is set to **50**:

- `Item A CostIncTax = 0.00 and Discount = 100` → Discount becomes **50**

- The macro updates Item A and adds the returned item cost to the rebalance value

- If the calculated rebalance value is **5.00**, the macro searches for a paid item where `CostIncTax > 5.00`

- `Item B PricePerUnit = 20.00` → PricePerUnit becomes **15.00**

- Item A receives `ItemValueChanged = Yes` in additional information

### **What This Means**

- Eligible zero-value items have their discount changed from **100** to the configured value

- A related paid item may be reduced to rebalance the order value

- Updated zero-value items are marked so the change can be identified later

- The macro log confirms when processing starts, errors occur, and the macro finishes

## **Final Summary**

The *Automated Discount Rebalancing for Zero-Value Order Items* macro helps adjust selected Linnworks orders that contain zero-value or negative-value items.

By checking each selected order, updating eligible items where `CostIncTax <= 0` and `Discount = 100`, marking changed items with `ItemValueChanged = Yes`, and reducing an eligible paid item by the calculated rebalance value, this macro supports a controlled item-level discount correction workflow.
