Function to recalculate shipping costs on subscriptions after renewal with Automatewoo

I’ve got a funky plugin that was custom made that adds a new random product from a group that a customer subscribes to.

Problem is, that the shipping doesn’t change depending on which product is selected, it stays with whatever was chosen initially.

Rather than paying more money to redevelop something that might already exist, is there any code that will recalculate shipping costs based on the item in the subscription? I have automatewoo, so could use a custom function from that and run it after a subscription payment has completed, I just don’t know how to code it.

Any support appreciated!


Confused about Google’s Cloud Platform costs

I’m having to migrate to Google’s "Web Risk" Lookup API after the terms of use were changed for their "Safe Browsing" product. Clicking the "Get started for free" button on the Web Risk overview page takes me to a Google Cloud Platform sign up page.

Reading the FAQ document related to this page is the source of my confusion about costs.

It says that new sign-ups get a 90 free trial, and $ 300 dollars of credit at the top of the document.

But the End of the Free Trial section says that once the 90 days are up, or the $ 300 credit has been spent:

To continue using Google Cloud, you must upgrade to a paid Cloud Billing account

To my mind this sounds like there’s a recurring subscription fee for Google Cloud regardless of whether you use any of the services therein. Is that an accurate interpretation? In other words, do you have to pay some sort of (monthly / yearly) subscription simply for having a "paid Cloud Billing account"?

Or is this description merely a way of indicating that use of some Cloud services may incur a fee once the value of the $ 300 dollar credit / 90 period has been used up?

I’ve been trying to find a clarifying statement about this, but haven’t been able to track anything down.

Thank you.

Do Order of the Scribes wizards have reduced spell learning GP costs?

The Player’s Handbook uses the following language to explain how wizards obtain spells:

Copying a Spell into the Book. When you find a wizard spell of 1st level or higher, you can add it to your spellbook if it is of a spell level you can prepare and if you can spare the time to decipher and copy it.

Copying that spell into your spellbook involves reproducing the basic form of the spell, then deciphering the unique system of notation used by the wizard who wrote it. You must practice the spell until you understand the sounds or gestures required, then transcribe it into your spellbook using your own notation.

For each level of the spell, the process takes 2 hours and costs 50 gp. The cost represents material components you expend as you experiment with the spell to master it, as well as the fine inks you need to record it. Once you have spent this time and money, you can prepare the spell just like your other spells.

The "Wizardly Quill" ability in the Unearthed Arcana that first described Order of the Scribes wizards used the following language:

• The quill doesn’t require ink. When you write with it, it produces ink in a color of your choice on the writing surface.

• The gold and time you must spend to copy a spell into your spellbook are halved if you use the quill for the transcription.

In the final release of the class through Tasha’s Cauldron of Everything, the language has changed to the following:

• The quill doesn’t require ink. When you write with it, it produces ink in a color of your choice on the writing surface.

• The time you must spend to copy a spell into your spellbook equals 2 minutes per spell level if you use the quill for the transcription.

There are, it seems, at least two interpretations of how this affects spell learning costs:

  1. Wizardly Quill does not say anything about the GP cost of learning spells, and therefore, the costs remain unchanged.
  2. Wizardly Quill reduces the cost of ink to 0 GP. Spells cost 50 GP/level when learning spells that require costly material components (e.g. Find Familiar). Spells cost 0 GP/level when learning spells whose material components are substituted by an arcane focus (e.g. Feather Fall).

My inclination, based on the Rule of Specificity, is to rule for the first option.

What spells with material costs or permanent effects could the Warlock: The Genie’s Limited Wish ability apply to?

I’m looking for ways to take the most advantage of this new ability from the upcoming Tasha’s Cauldron of Everything:

You entreat your patron to grant you a small wish. As an action, you can speak your desire to your Genie’s Vessel, requesting the effect of one spell that is 6th level or lower and has a casting time of 1 action. The spell can be from any class’s spell list, and you don’t need to meet the requirements in that spell, including costly components; the spell simply takes effect as part of this action. Once you use this feature, you can’t use it again until you finish 1d4 long rests.

Most of the spells with material costs or permanent/"until dispelled" effects I’ve come across either have a cast time longer than 1 action, or are level 7 or higher. So far the only spells I’ve found are Revivify and Continual Flame. What else am I missing?

Does Concurrent Infusions allow you to skip the XP costs and material components of the infusions it applies?

Concurrent Infusions is a 4th level Artificer infusion that lets you apply the effects of three 1st level infusions, all at once, without actually ‘casting’ them.

You channel your artificer talents through an increased number of minor infusions. When you cast this infusion, you can imbue the target object with the effects of three different 1st-level infusions chosen at the time of casting. The infusions function exactly as if you had cast them on the object, and do not count against your daily allotment. (emphasis mine)

The argument I’ve seen is that this is insanely broken, as it lets you use 1st level infusions without paying the XP cost or material components (in particular, Spell Storing Item lets you cast any 4th level or lower spell in the game). However, the section I’ve bolded makes me wonder if that’s actually the case. Does it refer only to the effects of the infusions, or does it mean you also have to pay their costs "exactly as if you had cast them"? Is there any precedent one way or the other?

What ways are there to cast resurrection magic without paying material costs?

An example of a method which gives the party access to free resurrection magic is casting True Polymorph to become a Planetar. Planetars can cast Raise Dead 3/day without paying the material cost.

This is not a duplicate of Are there any spell casters that can cast life giving spells without 'expensive' components? because I believe there are more methods of getting access to free resurrection than simply being these spellcasters. Also, the methods by which players gain access to those spellcasters may not exist within the system and may need the story to provide them.

What ways exist for a party of adventurers to get access to free resurrection?

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.

Shortest Path in a Directed Acyclic Graph with two types of costs

I am given a directed acyclic graph $ G = (V,E)$ , which can be assumed to be topologically ordered (if needed). Each edge $ e$ in G has two types of costs – a nominal cost $ w(e)$ and a spiked cost $ p(e)$ . I am also given two nodes in $ G$ , node $ s$ and node $ t$ .

The goal is to find a path from $ s$ to $ t$ that minimizes the following cost: $ $ \sum_e w(e) + \max_e \{p(e)\},$ $ where the sum and maximum are taken over all edges of the path.

Standard dynamic programming methods show that this problem is solvable in $ O(E^2)$ time. Is there a more efficient way to solve it? Ideally, an $ O(E\cdot \operatorname{polylog}(E,V))$ algorithm would be nice.

This is the $ O(E^2)$ solution I found using dynamic programming, if it’ll help.

First, order all costs $ p(e)$ in an ascending order. This takes $ O(E\log(E))$ time.

Second, define the state space consisting of states $ (x,i)$ where $ x$ is a node in the graph and $ i\in \{1,2,…,|E|\}$ . It represents "We are in node $ x$ , and the highest edge weight $ p(e)$ we have seen so far is the $ i$ -th largest".

Let $ V(x,i)$ be the length of the shortest path (in the classical sense) from $ s$ to $ x$ , where the highest $ p(e)$ encountered was the $ i$ -th largest. It’s easy to compute $ V(x,i)$ given $ V(y,j)$ for any predecessor $ y$ of $ x$ and any $ j \in \{1,…,|E|\}$ (there are two cases to consider – the edge $ y\to x$ is has the $ j$ -th largest weight, or it does not).

At every state $ (x,i)$ , this computation finds the minimum of about $ \deg(x)$ values. Thus the complexity is $ $ O(E) \cdot \sum_{x\in V} \deg(x) = O(E^2),$ $ as each node is associated to $ |E|$ different states.

Force-directed graph optimization with step-wise costs and constraints


I have an optimization problem. There are up to 25 nodes. The connectivity between the nodes is far less important than the Cartesian placement of the nodes. Since all nodes can potentially affect each other in the optimization problem it is safe to model this as a complete, undirected graph.

In most modes of this optimization problem there are between 2-3 regions extending out infinitely from the origin separated by straight lines, i.e.

 A | B --------    C 

Each region exactly encompasses one or more Cartesian quadrants. Each imposes a fixed cost or benefit to each node, but this cost does not change the "farther into the region" a node gets.


This is the exhaustive list of costs and constraints on the nodes; all factors are cost multipliers (higher is worse). Distances are shown in metres but are really just discrete integers.

  • The distance between any two nodes must be at least 4m
  • For each node pair within 25m, there is a factor of 1.04
  • For each node, if there are three or fewer other nodes within 120m, there is a factor of 0.90
  • Depending on what region a node is in, the node has a factor between 0.90 and 1.10
  • For every node, there is an individual edge factor to every other node within 25m of between 0.90 and 1.10
  • The product of all of the above factors, for each node, will have a set minimum of 0.67 and a set maximum of 1.50

So none of the factors are continuous, and none are differentiable in space since they are all step-wise.

Search space

The 2D coordinates of each node are discrete and unbounded. Since there are 25 nodes, there are 50 integer variables (xy for each node) to optimize. The hope is that even though there are no bounds, there will be enough sub-1.0 factors to have the optimization converge rather than force the nodes to fly apart.

If I get this working well enough for a given region configuration, I might expand this to selection of a region configuration, for which there are currently 46 possibilities.


Since none of the cost factors are space-differentiable, something like Gradient Descent would not be possible.

I have read about force-directed graph drawing; in particular this is interesting:

using the Kamada–Kawai algorithm to quickly generate a reasonable initial layout and then the Fruchterman–Reingold algorithm to improve the placement of neighbouring nodes.

Unfortunately, it seems that these methods have no notion of cost tied to absolute location, only distance of nodes relative to each other.


I will probably end up implementing this in Python.

Any hints on how to approach this would be appreciated.

FFG SWRPG mechanic payment costs

In an Fantasy Flight Games Star Wars RPG Campaign:
For various reasons I want to pay a random NPC mechanic to perform an attachment modification check on my weapon instead of my character doing it himself. Assuming I supplied all materials and supplies what would be a expected base cost for his services (assume Core World legal establishment ~Rebellion era).

This comes up because my GM has a GM-PC droid which I “own”. He forces me to pay said droid any time I want him to do anything (including mechanics checks). This is sometimes way overpriced for mundane things like this, which is fine because I can just find another mechanic somewhere on a world somewhere. The mechanic will then charge me an even more ridiculous amount with no negotiation forcing me to use “my” droid. I need proof of correct base amounts to show my GM to clarify what the mechanic should be paid, regardless of what the droid demands.

Thank you.