Add Cart Fee Based on Date Time for Specific WooCommerce Products

$75.00

This PHP code adds functions which enable you to add different cart fees based on the time and or day of the week in WooCommerce.

The code includes 5 examples which execute based on :

  1. By the hour. Example : 6pm which is 18 or 9am which is 9.
  2. Time. Example : between 9am and 6pm.
  3. Day & time. Example : on Thursday between 9am and 6pm.
  4. Weekend. Example : either Saturday or Sunday.
  5. Day. Example thursday.

The code also enables you to set different fee’s based on the above date and time. If the conditions are met, the first price is displayed otherwise another price is shown.

The following gallery images show different fee’s added to the cart totals based on time, day and day and time.

Installation & Setup

There’s 2 steps :

  1. Copy & paste the code to the end of your child themes functions file or custom functions/code snippets plugin.

  2. Set the product id on line 15 and the fee on line 37 using any of the day time variables. By default the fee is set to $day. Change this to any of the following : $hour, $time, $day_time, $weekend

These solutions may also help :