• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Filtering orders via status using liquid?

Explorer ,
Feb 03, 2017 Feb 03, 2017

Copy link to clipboard

Copied

Hi,

I'm trying to filter customer orders based on the order status, if the status is Pending then the order ID, name and an upload artwork button will show. I've managed to get it to work but the solution sucks since it creates way too many if statements so I'm looking for some advice. I tried a for loop but I couldn't get it to work as it looped through all orders but I couldn't find a way to filter via the order status. Embarrassingly I have spent God only knows how many hours on this haha

{module_order render="collection" filter="all" collection="allorders" template=""}

    

        {% if allorders.items.[0].status == 'Pending' %}

        <p>{{allorders.items.[0].id}}</p>

        <p>{{allorders.items.[0].orderName}}</p>

        <a class="btn color-bg" href="#">upload artwork</a> {% endif %}

       

        {% if allorders.items.[1].status == 'Pending' %}

        <p>{{allorders.items.[1].id}}</p>

        <p>{{allorders.items.[1].orderName}}</p>

        <a class="btn color-bg" href="#">upload artwork</a> {% endif %}

       

        {% if allorders.items.[2].status == 'Pending' %}

        <p>{{allorders.items.[2].id}}</p>

        <p>{{allorders.items.[2].orderName}}</p>

        <a class="btn color-bg" href="#">upload artwork</a> {% endif %}

Thanks,

Pete

TOPICS
Developer

Views

362

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 04, 2017 Feb 04, 2017

Copy link to clipboard

Copied

Use module_data insted which has WHERE you can build your needed query.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 06, 2017 Feb 06, 2017

Copy link to clipboard

Copied

LATEST

Liam is 100% correct.

I would super highly recommend installing the BC API Discovery app which would build your {module_data} query string for you.

BC API Discovery

Without knowing what fields you need etc, here is a be all and end all module data call...

{module_data resource="orders" version="v3" fields="id,siteId,entityId,categoryId,statusTypeId,discountCodeId,shippingOptionId,paymentMethodTypeId,taxCodeId,giftVoucherId,cycleTypeId,directDebitTypeId,integrationId,parentId,assignedUserId,name,countryCode,shippingPrice,shippingTaxRate,discountRate,giftVoucherAmount,totalPrice,shippingDescription,shippingAttention,shippingInstructions,quote,invoiced,invoiceNumber,invoiceDate,recur,nextInvoiceDate,endRecurDate,directDebitDays,directDebitProcessed,createDate,lastUpdateDate,destinationAddressIsResidential,isIntermediate,shippingRateKey,status,discountCode,workflow,customer,company,taxCode,assignedUser" skip="0" limit="10" where="\{'status.label':'Pending'\}" order="id" collection="myData"}

<pre>{{myData|json}}</pre>

Use BC API Discovery to build and test your own module_data calls to make the data returned as fast and efficient as possible.

Hope this helps.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines