Woocommerce Subscription Pricing/Billing Schedule

We are currently building a site using the Woocomerce Subscriptions plugin. When adding a product to the cart a customer inputs their information on the product page and it returns a calculated price for that order.

add_filter( 'woocommerce_add_cart_item_data', 'custom_add_to_cart_item_data', 20, 2 ); function custom_add_to_cart_item_data( $  cart_item_data, $  product_id ) {  ...  // Calculate total price based on weight  $  totalPrice = calculateTotalPrice($  product, $  plan, $  weight);   // Set calculated price to be the result of total price  $  cart_item_data['price_based_on_input'] = $  totalPrice; } 

We then check if price_based_on_weight is set and we update the price:

add_action( 'woocommerce_before_calculate_totals', 'add_custom_price_to_cart_item', 9999, 1); function add_custom_price_to_cart_item( $  cart ) {     // WC 3.0+     if ( is_admin() && ! defined( 'DOING_AJAX' ) )         return;     // Avoiding hook repetition     if ( did_action( 'woocommerce_before_calculate_totals' ) >= 2 )         return;      // Loop through cart items     foreach ( $  cart->get_cart() as $  item ) {         // Check if price_based_on_input is set         if( isset( $  item['price_based_on_input'] ) ) {             // Store price_based_on_input in a new variable             $  price = $  item['price_based_on_input'];              // Set the price of the item to the price_based_on_input             $  item['data']->set_price( $  price );         }     } } 

What we need to be able to do is update the subscription price based on the user’s input as well as update the billing schedule which will be based on what the user has entered on the product page, through custom form fields. The billing schedule would be different for each customer as they might have a schedule of being billed every 14 days and another customer might have a billing schedule of every 21 days. You can set this manually in the backend but it needs to be run automatically when the price is calculated.

Having referenced the documentation it looks like the two hooks that look usable for this are:

1. woocommerce_checkout_subscription_created - Triggered when a subscription is created after a customer purchases a subscription product or products. 2. subscriptions_created_for_order - Triggered when the subscriptions in an order are first created with the pending status. This occurs before payment has been made on an order and subscriptions are activated. 

Schedule Optimization With Priority and Weighted Costs

I need an algorithm to determine the best itinerary for a series of events.

Each event has a time, location, and reward. Arriving at an event in time yields the reward; too late means no reward. Each event is at a physical location thus it takes time to travel from event to event. It is not necessary to attend every event.

What itinerary will yield the largest total reward?

Does anyone know if there is an existing algorithm for this or one that would be easily adapted? Given the similarity to the traveling salesman problem I am tempted to start with a weighted TSP solution and work from there.

How to compute the number of occurrences of a cron schedule over a time span?

For example, given a cron schedule such as: 0 * 1 7 6 and a time span, like the next year, can you directly compute the number of times the schedule will fire? It can be brute forced pretty trivially but I’d like to use this to sort a list so I’d rather not just brute force it. It’s pretty easy to compute the trivial cron patterns:

fn('* * * * *', 1 day) -> 60 * 24 fn('0,30 * * * *', 1 day) -> 2 * 24 

It’s easy up until the calendar gets involved with different length months and then you have to worry about days or the week coinciding with days of the month.

Schedule X Classes In N Classrooms

I would really appreciate any thought on this, or under which category does this problem fall (Interval scheduling, Interval partitioning,…) I am really out of thoughts

I have X number of classes each with starting, and finishing time, and N number of free classrooms. And i want to find the maximum number of non-conflicting classrooms that can be scheduled in those N classrooms.

What I’ve tries so far :

– First algorithm:

  • Sort Classes in ascending order according to the finishing time of each class.
  • Starting with the minimal finishing time, pick all the intervals that don’t conflict with it and save it in a subset.
  • Repeat the first two steps on the very next interval that conflicts with the one we were working on before.

Why wrong ?

Ex: we have 4 classes (1,4) (2,6) (6,7) (4,8) and we want to find the maximum number of non-conflicting ones that can be fit in 2 classes.

  • Starting the algorithm on (1,4) will give me subset {(1,4)(6,7)} that can be fit in the first classroom, and in the second classroom i need to put either (2,6) or (4,8) but not both since they conflict, so in total 3 of those classes can be fit in 2 classrooms using this approach.
  • However in real life you can put {(1,4),(4,8)} in a room and {(2,6),(6,7)} in the other, so all of the classes can be held in the 2 rooms.

– Second algorithm

  • Sort Classes in ascending order according to the starting time of each class.
  • Starting with the minimal starting time, pick all the intervals that don’t conflict with it and save it in a subset.
  • Repeat the first two steps on the very next interval that conflicts with the one we were working on before.

Why wrong ?

Ex: we have 4 classes (1,2) (2,1000) (6,7) (7,8) and we want to find the maximum number of non-conflicting ones that can be fit in 1 class.

  • Starting the algorithm on (1,2) will give me subset {(1,2)(2,1000)} that can be fit in the first classroom, and that’s it, so in total 2 of those classes can be fit in a classroom using this approach.
  • However in real life you can put {(1,2),(6,7),(7,8)} in a room and, so 3 of the classes can be held in a room.

Thanks in advance

Schedule a Seminar in Minimum Time

There are t1, t2, t3,…..,tn topics which are to be scheduled in a building with c1,c2,c3,….ck halls. Members have already registered there interests on the topics, and they have liberty to choose any number of topics. There will be only one session on a given day per hall.

The problem is to finish the seminar in minimum time with least members missing on their topics.

My Solution:

For strictly no one missing on the topics there can be only one session on a day in only one hall and rest halls to be left unused. This takes longest possible time to finish the event. Only when all the k halls are utilized simultaneously, we can do it fastest.

Lets assume that ti is the set of all members interested in the i-th topic.

I am looking at a brute force solution in which we observe combinations of k topics (one topic per hall) to be scheduled at once. The effort is to find out intersection of groups in which cardinality of set with members choosing all those k-topics is minimum. Initially, there are nCk combinations, and after we schedule the first k-topics we can look for next n-kCk and then n-2kCk, n-3kCk… topics and so on.

As we see here, the main effort here is to find the intersection of k-sets. To me it looks like there should be some dynamic programming mechanism to reduce the repeated effort which I am unable to figure out. Do we have some thing absolutely different?

It is not a homework.

What is an example of a schedule that is strict but not serial?

According to the definition of a strict schedule a value written by a transaction T is not read or overwritten by other transactions until T either aborts or commits.

Also, we say that the set of serial schedules is a proper subset of the set of strict schedules.

So what can be an example of a schedule that is strict but not serial? I am just not able to imagine one.

Thanks.

Schedule each entree so that all entrees are completed in the shortest amount of time

Lets say we have plenty people to dress up entrees, but only one chef to cook them. Each entree E_i, takes c_i time to cook and d_i time to “dress up”. The dressing up of entrees can occur while other entrees are being cooked and dressed up, but we can only cook one entree at a time. How would you go about creating an algorithm to schedule each entree E_i in a manner that they all get finished in the shortest amount of time?

create an alexa flash briefing and make it easy to schedule content for $65

Sit back and relax. We will create your Amazon Alexa Echo Flash Briefing for you. Have you thought about expanding the reach of your original content to a new audience via a new medium? Then you need to be taking advantage of Alexa Flash Briefing Skill.If you’re thinking, “I want to reach a new audience with Echo device” then lets connect to help you with the following:Create the Alexa Flash Briefing Skill for your podcast, email newsletter, vlog, blog, YouTube channel, comedy show, interview, and more.Publish on the Amazon Skills store.Manage your flash briefing by updating the content daily, weekly, or monthly. Once it’s complete, we’ll provide you with the stats. This platform makes publishing content to Amazon Alexa quick and easy. We’ll bring a smile to your face the first time you hear your voice coming out of Alexa or we can use text to speech and let Alexa read it out. If you choose Standard or Premium, we will also provide you the platform’s scheduling tool. This tool makes publishing even faster and easier. You’ll be able to schedule your content. Then it will publish automatically at the time you select. Get excited to dominate the voice first market!

by: textsocial
Created: —
Category: Content & Writing
Viewed: 237


How to schedule events optimally given when the events are available?

Suppose I had a dictionary that contains events and the corresponding periods they are occurring. For example:

$ $ \begin{align} \textrm{Event 1} &\rightarrow \textrm{[1, 2, 3]} \ \textrm{Event 2} &\rightarrow \textrm{[2, 4]} \ \textrm{Event 3} &\rightarrow \textrm{[4]} \ \textrm{Event 4} &\rightarrow \textrm{[2, 3]} \end{align} $ $

How would I go about generating a schedule so that the events are scheduled optimally? For the example above, one possible optimal schedule would be:

$ $ \begin{align} \textrm{Period 1} &\rightarrow \textrm{Event 1} \ \textrm{Period 2} &\rightarrow \textrm{Event 2} \ \textrm{Period 3} &\rightarrow \textrm{Event 4} \ \textrm{Period 4} &\rightarrow \textrm{Event 3} \ \end{align} $ $

Is there any way to do this in better than checking every permutation? This seems like the reverse of the graph-coloring problem for scheduling, so is there any way to construct a graph to encapsulate this relationship and maybe find a shortest path? Can someone point me in the right direction on how to approach this?

schedule Full, Differential and Transnational Backup in sql Server 2016

I studied about scheduling backup with SQL Server Agent and Maintenance Plans (which leads to the SQL Server Agent).

My first concern is what is the best way to schedule my backups?

I want Full Backup everyday, Differential Backup every hour and Transnational Log Backup every 15 mins. My second concern, Is this a good practice?

I noticed an issue when I used SQL Server Agent. My full and Differential backup overwrites. I am ok with having the Full Backup overwrites but not for the differential since when I need to recover it, I would only have one Differential backup which is not the purpose of differential backups. How can I Not let this overwrite on previous backups?

The last concern and question is regarding the way to implementing the backup scheduling. I am going to use Maintenance Plans , and may schedule three different backups. One for full, one for differential and one for transnational. Is this the best practice for a database that is used everyday by users?(at least 2000 transactions per day)