Blog posts of '2015' 'September'

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.





Fee Expression




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






[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)
Payment Director and PayPal Express- Tuesday, September 22, 2015

PayPal Express is a "button" payment method, which means it appears as a button on the shopping cart page.  That said, your Payment Director expression won't be able to make use of ShippingAddress attributes, because a shipping address does not get selected by the customer until later in the checkout flow.  

So, for example, if you wanted to only allow PayPal Express for US customers, you can't use ShippingAddress.Country.TwoLetterIsoCode .  Instead, one workaround is to require a Country be entered during customer registration.   "CountryId" is an attribute stored with the Customer. 

Here's what it should look like in Payment Director grid: 



Customer.GetAttribute("CountryId") = "1"

Note the "1".  That's the CountryId.  You'll need to verify (or change) the "1" for country of your choice. "US" is typically "1", but it could vary depending on your nopCommerce configuration.  To verify/get the Id, Edit your country in Admin > Configuration > Countries, and check the browser's address bar.  Check the # on the end of the url  - e.g.  /Admin/Country/Edit/1

(See this blog for additional information: Payment Director - checking the selected shipping method)

Comments (1)