I have a Woocommerce shop and I'm using the Woocommerce REST API to list products etc. on another site and it works fine. There are some functionality that I'm missing though, and I'm wondering if it is possible to extend the API with custom calls?
I was able to figure out how to this by reading the source code for Woocommerce.
First I had to create a class that extends WC_API_Resource and add my routes in the register_routes method of this class. Then I had to make sure that Woocommerce adds this class to the API by adding the class to the class-array in the woocommerce_api_classes filter.
Related
I found out that you can place an order via WooCommerce but also in Mollie. See links below:
Mollie: https://docs.mollie.com/reference/v2/orders-api/create-order
WooCommerce: https://woocommerce.github.io/woocommerce-rest-api-docs/#create-an-order
What is best practice when using an API call? Create an order in Mollie, or WooCommerce, or both? I am not sure what happens if you place an order via the website... I also cannot test that.
Edit: I could test in on the website. The Wordpress WooCommerce website makes an order on both platforms, Mollie and WooCommerce.
Thanks!
I have a Wordpress website and want to add custom flow of registration.
The current website has these pages but I am not sure if there is any plugin that has inbuilt such flow feature or how to add this feature.
Any help appreciated.
I had to do a similar modification.
Your case seems the same as mine, its a single form, split onto steps for helping users/validations.
I didn't found any plugin ready for all i needed (the steps thing), and mainly ... hooks to change registration form in wordpress just add extra fields to standard fields, i needed to completly remix the order, so I went the javascript way:
Added my custom css and JS to login/register pages with the action 'login_enqueue_scripts'
Added my custom fields to form using 'register_form' action
Added a class to login body with 'login_body_class' filter, to keep things hidden while JS magic happened;
I'm not sure what's your skill level in JS, but once you got those hooks ready you can make pretty much whatever you want with the register form.
I'm using the WooCommerce REST API (http://woocommerce.github.io/woocommerce-rest-api-docs/#introduction) and are able to download Customers, Orders etc successfully.
My customer has added some custom fields to the checkout page, e.g.:
po_number
accounts_email
I would like to be able to GET these custom fields when requesting an ORDER, e.g.:
/wp-json/wc/v1/orders/4568
At the moment none of the custom fields are returned when I GET an Order. I've tried adding
?filter[meta]=true
to the request URL but that doesn't make any difference. Is there a way I can modify the GET URL to include all custom fields? Couldn't find any reference in the REST API docs to custom fields.
I have struggled like you did, but then it turns out using the newer v2 REST API solves the issue for me. So instead of:
/wp-json/wc/v1/orders/4568
I now use:
/wp-json/wc/v2/orders/4568
And custom fields will be included in the response with the key meta_data, even with those hidden fields starting with _.
I'm trying to use the value of one custom field on multiple pages and posts. I'm a newbie to PHP and custom fields so what I'm trying to accomplish could possible be done using a different method.
I have a WPMU setup with all new sites created from a default blog that includes multiple custom post type templates. When users create a new site they are redirected to their site admin dashboard.
Here comes my challenge, I want users to be able to enter information into form fields contained in metabox(es) on their admin dashboard (not post editor) that will be used on the various custom post type templates. For example, a user will need to enter their company name, address, logo, etc.
Depending on the temple, the information entered into the form fields will be used on the frontend of the site. For example, the company logo will be display where the custom field or shortcode is placed on the post template.
I'm having issues using custom fields for this because each custom field is specific to each post. In addition, I'm having issues rendering a form on the admin dashboard for this.
I'm also thinking that custom fields may not be the best way to accomplish my objective because they are usually post specific. I'm really asking for a variable that will be used globally and is static unless the user updates the form.
I'd appreciate any assistance on this.
The options API is what you will need for this:
http://codex.wordpress.org/Options_API
There's also some plugins and frameworks you can use to help such as:
https://wordpress.org/plugins/options-framework/
https://wordpress.org/plugins/redux-framework/
I'm new to wordpress. I have to create a one page template for my site and show a subscribe textbox on it with my own custom style. Later, I will use it to send monthly newsletters. What can be the simplest way to do that? I saw into some plugins like newsletter, subscribe2, but they are complicated and I don't know how to integrate them with my text box. They just provide some sort of widget to show on sidebar. Any tutorial or simple plugin? Please help!
You basically have three options:
a. Use a web-hosted syndication service as per the below. (Easiest to configure)
b. Install some sort of newsletter sending plugin for WordPress. (More control, but more configuration)
c. Use a web-hosted newsletter service like Constant Contact (Expensive and Ugh.).
Try using Feedburner with email subscriptions -- see: http://howtotechtips.blogspot.com/2008/05/create-feedburner-email-subscription.html. You sign up, supply your RSS feed's address, then copy-paste the resulting code where-ever in your template you like. Then, whenever you write a new post, your subscribers are sent an email.
Subscribe2 complicated?
You can do auto-download/install from the administration area, you literally only have to config a few options.
http://codex.wordpress.org/Managing_Plugins#Installing_Plugins
Maybe it's just me, but the screenshots certainly make the plugin appear to be very straight-forward.
http://wordpress.org/extend/plugins/subscribe2/screenshots/
If you are not heavy with subscription list. Then a good option can be using the MailChimp email subscription with its free option.
You can just install the plugin and place a function called mailchimpSF_signup_form() into your template's right place. And beautify it with your own CSS.
Or in Post or pages' HTML using the shortcode [mailchimpsf_form]
They also have widget to be added dynamically. How to use it?
Create a free account at MailChimp.
Create a list there.
Create an API key there
Go to your MailChimp options page http://yourwordpress.tld/wp-admin/options-general.php?page=mailchimpSF_options
Insert the API key there.
Select the list you want this subscription to be linked to.
There you are!