• Resolved beronu

    (@beronu)


    My technical question

    Would it be feasible to use the WordPress REST API to send: an item’s dimensions and weight, its delivery address,  and its delivery speed, to a Google Sheet (which I would have created in order to calculate the shipping charge of the heavy and/or bulky items I intend to sell), via the Google Sheets API (which is a RESTful interface), and then, normally, within a couple of seconds, receive back the shipping charge for that item?

    My use case

    Many of the items I’m planning on selling are bulky and/or heavy items which will normally ship as freight. Calculating freight charges tends to be complex; yet, of course, performing the actual calculations would be trivial for a spreadsheet, such as a Google Sheet. However, such calculations apparently cannot be done with WooCommerce OOTB (out-of-the-box).

    When a customer adds an item to his shopping cart in WooCommerce, within a couple of seconds I would like the shipping charge to have been calculated in a Google Sheet and sent to WooCommerce, where, of course, it will be displayed for the customer to see.

    Why not use a plugin for WooCommerce?

    I suppose I might be able to find a plugin for WooCommerce to perform the calculations, but frankly, even if I could I would rather not use a plugin for three reasons.

    First and foremost, although WooCommerce itself is relatively secure; many of the plugins for WooCommerce are insecure.  Therefore, the fewer WooCommerce plugins I use, the better. (I am not complaining; rather, I am explaining).

    Second, I read many user comments about WooCommerce plugins, wherein users complained that a particular plugin didn’t work properly.

    Third, Google Workspace (which subsumes Google Sheets) has been extremely reliable for me for over 15 years.  Therefore, if it would be feasible to use it in this case, I would like to adhere to the adage, “If it ain’t broke don’t fix it.

    Final Note

    When I indicated above, “… performing the actual calculations would be trivial for a spreadsheet, such as a Google Sheet,” I did not mean to imply that setting up and maintaining the spreadsheet itself would be trivial. That would probably be a little bit of a chore. As I indicated above, I was referring to performing the actual calculations.

    • This topic was modified 10 months, 2 weeks ago by beronu.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter beronu

    (@beronu)

    Perhaps I need to use the WordPress HTTP API instead of the WordPress REST API.

    Moderator bcworkz

    (@bcworkz)

    Yes, use the HTTP API (specifically the WP_Http class) to send requests to the Sheets API. The WP API can only respond to requests, it cannot send them. However, your code can get the data you want to send to Sheets API from the WP API. Or directly query the WP DB.

    Thread Starter beronu

    (@beronu)

    Thanks for letting me know! Using the HTTP API and the WP_Http class to send requests to the Sheets API makes the most sense to me.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Using WordPress REST API to send data to and receive data from a Google Sheet’ is closed to new replies.