Blog posts tagged with 'Day-of-week'

RSS
"Saturday Delivery" method, but only show it on Friday- Sunday, October 11, 2015


You can use the day of week in your expressions.  For example, if you need to have Saturday Delivery, but only want to show that option on Friday, here's an example using Shipping By Weight. You can create another Shipping Method (e.g.  "Saturday Delivery"), and Shipping Director can exclude it conditionally (when not Fri) by using Name Expression.

The Name Expression would look like this (assuming your method name has the word "Saturday" in it - e.g.  "Saturday Delivery") :

    [$Name].Contains("Saturday") and DateTime.Today.ToString("ddd") <> "Fri" ? "" : [$Name]

Note, though, that you may also want to check the Time too (because if they place the order Fri at 11pm, you may not be able to get it there Sat ;)

Another example would be to show an additional set of shipping options with a surcharge.  For example, if you use Shipping By Weight, you can call it twice with the Option type. The 2nd call would check if the country is Belgium and the day of the week is Thu or Fri; it would have a Surcharge Expression, in this case just a fixed 2.50:

Order

Type

Name

Expression

Rate Expression

Surcharge Expression

110

Option

By Weight

true

Shipping.ByWeight

 

100

Boolean

AllowSaturday

Country = "BE" and "Thu,Fri".Contains(DateTime.Today.ToString("ddd"))

 

 

120

Option

By Weight Sat

[AllowSaturday]

Shipping.ByWeight

2.50

Tags :  Day-of-week
Comments (2)
Payment Director - Charge a Fee for Rentals late in the day- Tuesday, September 22, 2015

Here's one way to charge a fee to "rentals made after 1pm of a rental starting today" 

Note that RentalStartDateUtc  has Utc suffix, but since current nopC only supports Date and not time for rentals, I don't know if it has any impact - my test shows that when I entered item in cart with today's date, that is what was stored in the database, even though I'm UTC - 5 which would have been UTC next day since I entered it at 9pm.   (There is no DateTime.UtcToday, but DateTime.UtcNow.Date should work in its place if you prefer to use  compare.)   Also, below I use DateTime.Now.Hour and not DateTime.UtcNow.Hour, because I'm comparing the current hour to see if it's later than 1pm my time (13:00) - but this time will also depend on the time of your server.

Order

Type

Name

Expression

Fee Expression

105

Boolean

ChargeAFee

DateTime.Now.Hour > 13 and Items.Any(Product.IsRental and RentalStartDateUtc = DateTime.Today)

 

110

Option

Payments.AuthorizeNet

Show

[ChargeAFee] ? 2 : 0

 

Adjust 13 to the hour of the day you need.  Adjust the "2" in [ChargeFee] ? 2 : 0 to be the fee you want to charge.

You need to enter a similar  line & fee expression for each payment method you've enabled.

 

Tags :  PD-FeeDay-of-week
Comments (6)