Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save trycf/16dad6e43b767f00974c1ad40d5e5fc3 to your computer and use it in GitHub Desktop.

Select an option

Save trycf/16dad6e43b767f00974c1ad40d5e5fc3 to your computer and use it in GitHub Desktop.
TryCF Gist
<cfscript>
<cfoutput>
<cfparam name="url.orderID" default="" />
<cfoutput>
<cfif url.orderID NEQ "">
<!--- ORDER DETAILS --->
<cfset orderDetails = $.slatwall.getEntity('order', '#url.orderID#')>
<cfif isNull(orderDetails) or (orderDetails.getAccount().getAccountID() neq $.slatwall.getAccount().getAccountID())>
<p class="noOrders">No orders found.</p>
<cfelse>
<!--- ORDER DETAILS --->
<div class="orderDetailBlock">
<a href="/my-account/order-items" class="pull-right">Return to Order Items</a>
<cfif listFindNoCase('ostNew,ostProcessing,ostClosed', orderDetails.getStatusCode()) NEQ 0>
<p>Order ###orderDetails.getOrderNumber()#<br>
Placed on: #dateformat(orderDetails.getFormattedValue('orderOpenDateTime'),'dddd, mmmm d, yyyy')#</p>
<cfif orderDetails.getStatusCode() EQ 'ostNew' AND isNull(orderDetails.getRemoteID())>
<div class="orderActions">
<a class="button button_sm" data-toggle="modal" href="##cancelOrderModal">Cancel Order</a>
</div>
<div id="cancelOrderModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Confirm Order Cancellation</h4>
</div>
<div class="modal-body">
#$.renderContent($.getContentByUrlTitlePath('components/modal-close-order').getContentID(), 'contentBody')#
<div class="center-block">
<a class="button button_sm" href="?slataction=public:account.cancelOrder&orderID=#orderDetails.getOrderID()#&sRedirectURL=/my-account/orders">Yes, Cancel My Order</a></p>
</div>
</div>
</div>
</div>
</div>
</cfif>
<cfelse>
<p>Order ###orderDetails.getOrderNumber()# has been cancelled.
</cfif>
<div class="row">
<div class="col-sm-4 orderDetailPickup">
<h4>Pickup Location</h4>
<div class="info">
<cfif ArrayLen(orderDetails.getOrderFulfillments()) GT 0>
<i class="fa fa-map-marker fa-2x icon-left"></i>
<address>
<cfloop array="#orderDetails.getOrderFulfillments()#" index="orderFulfillment">
<strong>#orderFulfillment.getPickupLocation().getLocationName()#</strong><br>
#orderFulfillment.getPickupLocation().getPrimaryAddress().getAddress().getStreetAddress()#<br>
<cfif len(orderFulfillment.getPickupLocation().getPrimaryAddress().getAddress().getStreet2Address())>#orderFulfillment.getPickupLocation().getPrimaryAddress().getAddress().getStreet2Address()#<br></cfif>
#orderFulfillment.getPickupLocation().getPrimaryAddress().getAddress().getCity()#, #orderFulfillment.getPickupLocation().getPrimaryAddress().getAddress().getStateCode()#, #orderFulfillment.getPickupLocation().getPrimaryAddress().getAddress().getPostalCode()#
</cfloop>
</address>
</cfif>
</div>
</div>
<div class="col-sm-4">
<h4>Order Summary</h4>
<div class="info">
<ul class="list-group">
<li class="list-group-item">Subtotal<span>#orderDetails.getFormattedValue('subtotal', 'currency')#</span></li>
<cfif orderDetails.getDiscountTotal() gt 0>
<!--- BUILD PROMO CODE LIST --->
<cfparam name="promotionCodeList" default="">
<cfif arraylen(orderDetails.getPromotionCodes())>
<cfset promotionsList = ArrayNew(1)>
<cfloop array="#orderDetails.getPromotionCodes()#" index="promotionCodeApplied">
<cfset tempSet = ArrayAppend(promotionsList, "#promotionCodeApplied.getPromotionCode()#")>
</cfloop>
<cfset promotionCodeList = ArrayToList(promotionsList, ",")>
</cfif>
<li class="list-group-item">Discount<cfif promotionCodeList NEQ ""> <span class="promoRed">(#promotionCodeList#)
</cfif>#orderDetails.getFormattedValue('discountTotal', 'currency')#</li>
</cfif>
<li class="list-group-item">Tax<span>#orderDetails.getFormattedValue('taxTotal', 'currency')#</span></li>
<li class="list-group-item">TOTAL:<span>#orderDetails.getFormattedValue('total')#</span></li>
</ul>
</div>
</div>
<div class="col-sm-4">
<h4>Payment Info</h4>
<div class="info">
<!--- Get the applied payments smart list, and filter by only payments that are active --->
<cfset appliedPaymentsSmartList = orderDetails.getOrderPaymentsSmartList() />
<cfset appliedPaymentsSmartList.addFilter('orderPaymentStatusType.systemCode', 'opstActive') />
<cfloop array="#appliedPaymentsSmartList.getRecords()#" index="orderPayment">
<div id="cartReviewBilling" class="orderReviewBlocks">
<cfif not isNull(orderPayment.getBillingAddress().getName())>
#orderPayment.getBillingAddress().getName()#<br />
</cfif>
<cfif not isNull(orderPayment.getBillingAddress().getStreetAddress())>
#orderPayment.getBillingAddress().getStreetAddress()#<br />
</cfif>
<cfif not isNull(orderPayment.getBillingAddress().getStreet2Address())>
#orderPayment.getBillingAddress().getStreet2Address()#<br />
</cfif>
<cfif not isNull(orderPayment.getBillingAddress().getLocality())>
#orderPayment.getBillingAddress().getLocality()#<br />
</cfif>
<cfif not isNull(orderPayment.getBillingAddress().getCity()) and not isNull(orderPayment.getBillingAddress().getStateCode()) and not isNull(orderPayment.getBillingAddress().getPostalCode())>
#orderPayment.getBillingAddress().getCity()#, #orderPayment.getBillingAddress().getStateCode()# #orderPayment.getBillingAddress().getPostalCode()#<br />
<cfelse>
<cfif not isNull(orderPayment.getBillingAddress().getCity())>
#orderPayment.getBillingAddress().getCity()#<br />
</cfif>
<cfif not isNull(orderPayment.getBillingAddress().getStateCode())>
#orderPayment.getBillingAddress().getStateCode()#<br />
</cfif>
<cfif not isNull(orderPayment.getBillingAddress().getPostalCode())>
#orderPayment.getBillingAddress().getPostalCode()#<br />
</cfif>
</cfif>
<cfif not isNull(orderPayment.getBillingAddress().getCountryCode())>
#orderPayment.getBillingAddress().getCountryCode()#<br />
</cfif>
<cfif not isNull(orderPayment.getBillingAddress().getPhoneNumber())>
#orderPayment.getBillingAddress().getPhoneNumber()#<br />
</cfif>
</div>
<p><i class="fa fa-credit-card"></i> #orderPayment.getCreditCardType()# ending in #orderPayment.getCreditCardLastFour()#</p>
</cfloop>
</div>
</div>
</div>
<h4>Order Items</h4>
<div class="cartReviewItems">
<!--- Cart Data --->
<table class="table">
<!--- Order Items --->
<cfset loopIndex=0 />
<!--- Loop through items on the order --->
<cfloop array="#orderDetails.getOrderFulfillments()#" index="orderFulfillment">
<cfif arrayLen(orderFulfillment.getOrderFulfillmentItems())>
<!--- Loop through items on the fulfillment --->
<cfparam name="local.productImage" default="">
<cfloop array="#orderFulfillment.getOrderFulfillmentItems()#" index="orderItem">
<cfset loopIndex++ />
<cfif orderItem.getSku().getProduct().getImageExistsFlag()>
<cfset local.productImage = "#orderItem.getSku().getProduct().getImagePath()#" >
</cfif>
<cfif isNull(orderItem.getSku().getRemoteID())>
<cfset local.productTitle = orderItem.getSku().getProduct().getProductName() />
<cfelse>
<cfset local.productTitle = orderItem.getSku().getSkuName() />
</cfif>
<cfset local.productURL = orderItem.getSku().getProduct().getProductURL() />
<cfset loopIndex++ />
<tr>
<td><img src="#orderItem.getSku().getProduct().getResizedImagePath(size="small")#"></td>
<td>#local.productTitle#</td>
<td>#orderItem.getFormattedValue('price')# / #orderItem.getSku().displayOptions()#</td>
<td>Qty: #orderItem.getQuantity()#</td>
<td class="totalValue">#orderItem.getFormattedValue('extendedPriceAfterDiscount')#</td>
</tr>
</cfloop>
</cfif>
</cfloop>
</table>
</div>
<cfif $.slatwall.hasSuccessfulAction( "public:account.applyPayment" ) OR orderDetails.getPaymentAmountDue() EQ 0>
<div class="alert alert-success">
<i class="fa fa-info-circle"></i> This order is paid in full.
</div>
</cfif>
<!--- If there is a balance remaining on this order, allow the user to pay using an account payment method. --->
<cfif orderDetails.hasDepositItemsOnOrder() AND (orderDetails.getStatus() EQ "Ready For Pickup" OR orderDetails.getStatus() EQ "New" OR orderDetails.getStatus() EQ "Processing") AND orderDetails.getPaymentAmountDue() GT 0> <!--- If they still owe payment --->
<h4>Pay My Balance</h4>
<cfif orderDetails.hasErrors()>
<div class="alert alert-danger">
Error: Unable to process this payment at this time.
</div>
</cfif>
<div class="cartReviewItems">
<!--- Pay Balance. --->
Use existing payment method.
<div style="width:40%">
<form action="?s=1" method="post">
<input type="hidden" name="slatAction" value="public:account.applyPayment" />
<input type="hidden" name="processContext" value="applyPayment" />
<input type="hidden" name="orderID" value="#orderDetails.getOrderID()#" />
<input type="hidden" name="fRedirectURL" value="/my-account/orders?orderID=#orderDetails.getOrderID()#" />
<input type="hidden" name="sRedirectURL" value="/my-account/orders?orderID=#orderDetails.getOrderID()#" />
<!--- Find the account payment method for the active payment. --->
<cfif arrayLen($.slatwall.account().getAccountPaymentMethods())>
<select name="accountPaymentMethod.accountPaymentMethodID" class="form-control" >
<cfset paymentMethods = $.slatwall.account().getAccountPaymentMethods()>
<cfloop array="#paymentMethods#" index="paymentMethod">
<option name="#paymentMethod.getAccountPaymentMethodID()#" value="#paymentMethod.getAccountPaymentMethodID()#">#paymentMethod.getCreditCardType()# **** #paymentMethod.getCreditCardLastFour()#</option>
</cfloop>
</select>
</cfif>
<!--- Find the payment method for the active payment on the order --->
<!---<cfif not isNull(orderDetails.getOrderPayments()) and arrayLen(orderDetails.getOrderPayments())>
<select name="paymentMethod.paymentMethodID" class="form-control" >
<cfset orderPayments = orderDetails.getOrderPayments()>
<cfloop array="#orderPayments#" index="orderPayment">
<cfif orderPayment.getStatusCode() eq 'opstActive'>
<option name="#orderPayment.getPaymentMethod().getPaymentMethodID()#" value="#orderPayment.getPaymentMethod().getPaymentMethodID()#">#orderPayment.getCreditCardType()# **** #orderPayment.getCreditCardLastFour()#</option>
</cfif>
</cfloop>
</select>
</cfif>--->
<br>
<a href="/my-account/saved-cards">Add New Card</a>
<br>
<div class="form-group">
<label class="control-label" for="amount">Amount</label>
<div class="controls">
<input type="text" name="orderPaymentAmount" value="#orderDetails.getPaymentAmountDue()#" class="form-control" />
</div>
</div>
<input type="submit" value="submit" class="form-control" />
</form>
</div>
<!--- NewOrderPayment Form --->
<!---Use New Payment Method.--->
<div style="width:40%; display:none">
<form action="?s=1" method="post">
<input type="hidden" name="slatAction" value="public:cart.addOrderPayment" />
<input type="hidden" name="processContext" value="addOrderPayment" />
<input type="hidden" name="orderID" value="#orderDetails.getOrderID()#" />
<input type="hidden" name="fRedirectURL" value="/my-account/orders?orderID=#orderDetails.getOrderID()#" />
<input type="hidden" name="sRedirectURL" value="/my-account/orders?orderID=#orderDetails.getOrderID()#" />
<input type="hidden" name="newOrderPayment.order.orderID" value="#orderDetails.getOrderID()#" />
<input type="hidden" name="newOrderPayment.orderPaymentType.typeID" value="444df2f0fed139ff94191de8fcd1f61b" />
<input type="hidden" name="copyFrom" value="accountPaymentMethod" />
<cfif arrayLen($.slatwall.account().getAccountPaymentMethods())>
<select name="accountPaymentMethod.accountPaymentMethodID" class="form-control" >
<cfloop array="#$.slatwall.account().getAccountPaymentMethods()#" index="accountPaymentMethod">
<option name="#accountPaymentMethod.getAccountPaymentMethodID()#" value="#accountPaymentMethod.getAccountPaymentMethodID()#">#accountPaymentMethod.getCreditCardType()# **** #accountPaymentMethod.getCreditCardLastFour()#</option>
</cfloop>
</select>
</cfif>
<br>
<a href="/my-account/saved-cards">Add New Card</a>
<br>
<div class="form-group">
<label class="control-label" for="amount">Amount</label>
<div class="controls">
<input type="text" name="newOrderPayment.amount" value="#orderDetails.getPaymentAmountDue()#" class="form-control" />
</div>
</div>
<input type="submit" value="submit" class="form-control" />
</form>
</div>
</div>
</cfif>
</div>
</cfif>
<cfelse>
<!--- ORDER LISTING --->
<div id="orderListingBlock">
<table class="orderListing table">
<tr>
<th>Order Date</th>
<th>Order Number</th>
<th>Order Total</th>
<th>Order Status</th>
<th>&nbsp;</th>
</tr>
<cfif arraylen($.slatwall.account().getOrdersPlacedSmartList().getRecords()) GTE "1">
<cfloop array="#$.slatwall.account().getOrdersPlacedSmartList().getRecords()#" index="order">
<tr>
<td>
<span class="orderListingDate">#dateformat(order.getFormattedValue('orderOpenDateTime'),'mmmm d, yyyy')#</span>
<span class="orderListingTime">#timeformat(order.getFormattedValue('orderOpenDateTime'),'h:mm tt')#</span>
</td>
<td>#order.getOrderNumber()#</td>
<td>#order.getFormattedValue('total', 'currency')#</td>
<td>#order.getStatus()#</td>
<td><a href="/my-account/orders?orderID=#order.getOrderID()#">View Order Details</a></td>
</tr>
</cfloop>
<cfelse>
<tr>
<td colspan="4"><p>No orders found.</p></td>
</tr>
</cfif>
</table>
</div>
</cfif>
</cfoutput>
</cfoutput>
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment