I am building a tool (SPA) which helps customers decide which product is best for them. The tool also allows them to make a purchase.
Built using vue.js, and originally intended to be embedded within a page on a Shopify store, I have been asked to replace Shopify with Woocommerce.
I've not used woocommerce in this way before (I typically use it as is, and make changes to templates via action hooks and templates).
The SPA will be embedded within a page on the woocommerce site. I see that woocommerce has an API, with various endpoints from which I can retrieve data, and post when a customer wishes to purchase.
Should I use this api, or, should I make woocommerce templates which return json? It seems sensible to use the API as its useful for this type of thing.
If using the API, will I need to authenticate against it using oauth etc? The SPA will exist within a page of the woocommerce site, within the same domain as the API.
Sorry, this is probably a poor question - I just need a nudge in the right direction. Does anyone have any pointers on the best way I should proceed? Thanks, Rob
答案 0 :(得分:1)
您可以查看使用WooCommerce REST API的Wordpress REST API。然后,您可以将内置Backbone Client与wp_enqueue_script('wp-api');
一起使用,并使用Backbone.Model和Collection来处理CRUD操作或其他JavaScript client libraries。
你可以define your own REST Endpoints
我认为这就是你要找的东西
当然还有老朋友AJAX ;-)