I want to programmatically delete old orders in Woocommerce, to try to assist database performance, so I am considering running this via the API documented below. The documentation doesn't detail exactly what is deleted - is it just the order, and its metadata? Does it delete the notes of an order for example?
https://woocommerce.github.io/woocommerce-rest-api-docs/#delete-an-order
Related
I have imported the products using some API's. But Every time I import the products, it's ask to regenerate the woocommerce lookup tables. So how can I run Regenerate Product lookup tables on WooCommerce -> Status -> Tools by cron jobs programmatically?
This issue is over a year old so I'm guessing you've either figured it out or moved on. I'm posting this here more as a shortcut for anyone looking into this in the future.
You have a few ways you can accomplish regenerating product lookup tables for WooCommerce.
1. Use the WooCommerce REST API
The WooCommerce REST API documentation is pretty helpful here. Do a GET request to get a list of all the available tools from system status, then run a PUT request as noted in the docs here - https://woocommerce.github.io/woocommerce-rest-api-docs/#retrieve-a-tool-from-system-status
You'll want to generate API keys in WooCommerce before making those requests. They've got it pretty well documented here as well - https://docs.woocommerce.com/document/woocommerce-rest-api/
2. Use the WP-CLI
If you're a die-hard WordPress developer you could benefit from using the WP-CLI tool - https://make.wordpress.org/cli/handbook/
You'd run the command wp wc tool run regenerate_product_lookup_tables --user=1
3. Bake it into the WordPress admin panel
As noted in the WooCommerce developer documentation you can use the update_lookup_table method from the WC_Data_Store_WP class - https://developer.woocommerce.com/2019/04/01/performance-improvements-in-3-6/
This feels overkill since you can just go to WooCommerce > Status > Tools > Product lookup tables and click the "Regenerate" button on the right. I guess it could be useful if you're using an automation tool like Selenium to log into your WordPress and do things. I could see the benefit of using update_lookup_table in a custom admin page or plugin to reduce the amount of clicks and page loads that your script would need to navigate.
What if you update your version of woocommerce,What happens to our data? Does it remain unchanged?
Your products, orders and customer data is stored in your database, so updating WooCommerce shouldn't affect them, but you should always backup your database before you update anything just in case something goes wrong. You can either use a plugin like WP migrate DB, or else export a copy of the DB via PHPMyAdmin.
If your theme uses custom templates for WooCommerce, these may have to be updated: WooCommerce will flag any templates that need updating.
If you've made any changes to the WooCommerce plugin files themselves you will definitely lose those changes: you should avoid editing plugin files directly.
Finally, it's worth reviewing the WooCommerce changelog to see what changes have been made and how they may impact you.
I need a WordPress plugin that can do comparison of different services, like the one on http://www.whoishostingthis.com/compare/
This is something that you will most likely have to program yourself. Mainly because there wont be many plugins that will go out to service provider websties, scrap the data, then aggregate it properly to compare on the field related to you.
In the sense of programming this you would want to do the following steps.
Determine what service providers you want to scrape
Scrape said providers for their prices (do it on a throttled basis or you will most likely get blocked by the providers website).
Aggregate the data and store it in a data store
Display the provider services while showing your comparison.
If you do not want to program this plugin yourself you can do a hybrid approach which requires a lot of manual intervention.
This site shows many "compare products" plugins that will allow you to compare 2 products in an ecommerce setting. If you use one of these plugins along with a wordpress ecommerce plugin you could manually enter each service provider as a "product" then display the product comparison.
https://wordpress.org/plugins/tags/compare-products
I am using Wooocommerce and an invoice/product inventory system which is implemented via Woocommerce API. I need live synchronization but the problem with this is that the inventory system is adding thousands of webhooks while synchronizing, which is making the site extremely slow. Does anyone know if it is possible to set up a cronjob to delete all webhooks in certain intervals?
Yes it is possible to setup a cronjob to delete all web-hooks. You can also delete a single or batch delete the web-hook. Here is the documentation link for batch and single web-hook delete link.
I've been assigned to add some features to an existing newspaper. This newspaper is based on Wordpress. They want to add a subscription feature for subscribed users to receive email with the latest news and some other stuff.
They also want a coupon system, which I'm planning to implement using CouponPress (http://www.couponpress.com/) which is a separate Wordpress installation for coupons.
They want to keep the subscribers functionality completely separated from the main blog to avoid opening security holes for attackers to gain admin or editor roles and mess with the newspaper.
What do you recommend for this?
If I keep the subscription feature attached to the second blog, is there a plugin or something to automatically email the subscriptors of the second blog with latest entries, a daily or weekly? I want the second blog to look as part of the first one for users. Maybe replicating the user list somehow in the main blog, but avoiding sign in on it.
What do you think?
Thanks for your help
just throwing an idea for the subscription feature, if you do go the path of subscription to the other blog you can write some quick and dirty function to query the new or even an sql trigger to copy new user recordds to the other db (I don't know if mysql allows for inter db copy triggers)
but - I don't really know what'll you'll achieve that way. if the data isn't secure and sanitized someone could try to run an sql injection. and then copying the record to the other db would contaminate it either.
better use on of wordpress good security plugins, harden server access etc