Blog posts tagged with 'PD-Fee'

RSS
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.



FYI, you may need to adjust for UTC:

DateTime.Now.Hour is Hour in the local time zone.

DateTime.UtcNow.Hour is Hour in UTC.

DateTime.Today gives you the current date in the local time zone.

DateTime.UtcNow.Date gives you the current date in UTC.


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