Blog posts of '2023' 'October'

RSS
Prevent showing shipping methods when there are products that require pickup in store- Sunday, October 29, 2023

NopCommerce won't show the "Pickup in store" if all items in the cart have shipping disabled.

In Shipping Director, you can workaround that by using an Unpublished Category - e.g., "Pickup Only".  First, be sure to select shipping enabled on the product (and add the product to the category).  Then SD can show an error message in the cart (and prevent checkout from continuing) if the cart contains any such item:

ErrorExit

Check pickup only

Items.Any(Product.HasCategory("Pickup Only"))

"Sorry, you have product(s) that require pickup in store."

Be sure to sequence (order / line #)  that ErrorExit rule before Option type rules.

Note that the above is using Items.Any() so if cart contains any "pickup only" items, the customer must backup to select Pickup.  Thta's because nopCommerce by default shows the "Pickup" checkbox in the shipping address page.  However, there is a setting that will instead show the "Pickup" checkbox in the shipping methods page.  In Administration > Settings > All Settings, search for ordersettings.displaypickupinstoreonshippingmethodpage, Edit it and change the Value to True.  Then when you have the above ErrorExit, the customer would see this in the shipping method selection page:


Tags :  Pickup
Comments (0)
Payment Director - checking the selected shipping method- Saturday, October 21, 2023

In Payment Director, you can check which shipping method/option was selected by the customer and use it to conditionally show a payment method.  For example, you might have

Option

Payments.CashOnDelivery

ShippingOption != null and ShippingOption.ShippingRateComputationMethodSystemName = "Shipping.ByWeightByTotal"

Note that that we prefix the expression with ShippingOption != null  (or you can write  ShippingOption <> null).  This is good practice, because if you have (or ever plan to get) a "button payment method" (that appears in the cart as a button under the chekout button), then Payment Director may get called "prematurely" with respect to not having the selected shipping method.  Having the null check will prevent erros being logged.

(See this blog for additional information: Payment Director and PayPal Express)

Comments (0)