Jump to content

Shipping plug-in: trigger action on order status update


Recommended Posts

Hi,

Apologies if it's a dumb question, I'm quite new to Cubecart. I'm currenctly working on developping a shipping extension. While I've seen that in the shipping.class.php it is expected that there is a public function calculate() to determine the shipping costs, I wonder whether any function could be called upon order or payment status update. The idea of course, would be to append the shipping details (tracking id) to the order.

Ideally I'd like to define a function which would be triggered on the order status update. But I'm not sure how I could define such a triggering. Any hints?

Best regards,

Guillaume

Link to post
Share on other sites

Let's look at the shipping.class.php files for UPS, USPS, and AIOS. Each has a public function tracking(identifier).

In the cubecart.class.php file, private function _orders(), this is used to show appropriate order summaries to the customer. Each order has recorded what shipping method was selected at checkout, so this function uses that method name to eventually call the related tracking() function from the shipping module.

The implied return value from calling the shipping module's tracking() function is the shipping company's URL containing the tracking number. (The _orders() function can deal with the case where the tracking(0 function returns something other than a URL, or if the function does not exist at all.)

It is when editing the order in admin, Delivery tab, one can enter just the tracking number or a complete URL.

Link to post
Share on other sites

Hi,

First of all, thanks a lot for your continuous - much appreciated. I guess what confused me is that in the modules AIOS, UPS and USPS, the tracking function is nearly empty, so I assumed it to be useless. What I tend to understand now, is that none of these modules allow the tracking number to be input automatically (which I understand for AIOS, as it solely aims at computing the shipping costs, but I would have expected UPS and USPS to integrate that).

What I am after is, upon payment completion, to have this tracking function called, having it generating a shipping label (I've got APIs for this), retrieve the tracking number, and input it in the dedicated order field.

I'm starting simple, trying to input a dumb number at first, just to see if my tracking function is called. It looks like this:

image.png.e6db68faf74f54b33c0006ff73904de9.png

I'm not sure I need $tracking_id = false (but I've tried true with the same result) and I'm not sure I need to return anything. I don't see the echo message, I don't see the debug message, and the ship_tracking number is not updated. I am therefore under the impression that my tracking function is not called.

But from your explanation I really can't see what I am doing wrong, the tracking function should be called anyways, shouldn't it?

Best regards,

Guillaume

 

Link to post
Share on other sites

"I would have expected UPS and USPS to integrate that."

I would suspect that if the USPS and UPS modules did anything more than make a Rate Request, such as schedule a package pickup, print authorized shipping labels, etc, etc, then those providers would include a tracking number that CubeCart's call to tracking() would detect and process.

So, a simple Rate Request would be too soon to ask for or expect a tracking number.

If I recall from my searching the codebase, in the cubecart.class.php file, private function _orders(), this is used to show appropriate order summaries to the customer. I did not find anywhere else where the tracking() function is called.

"What I am after..., retrieve the tracking number,..."

From where?

Link to post
Share on other sites

What I'm understanding from your answer is that, upon order completion (I'm guessing order status changed to pending?) then the _orders() function is called which we itself calls the tracking function. So I believe my tracking function should then be called?

My shipping provider doesn't charge for labels printed as long as the parcel isn't scheduled for shipping or shipped. So my intention was to use that tracking function to 1/ generate the label (I've got an API for this which returns the tracking number) 2/ associate the tracking number to the order, so that at a later stage the admin simply prints the label on the parcel and ships it.

But I believe I first need to clearly understand the trigger which calls the tracking function.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...