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
Copy link to clipboard
Copied
Use module_data insted which has WHERE you can build your needed query.
Copy link to clipboard
Copied
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.
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.