I'm working on a woocommerce site, and i'm facing a problem.
I'm updating the products, the products are sorted alphabetically, but all the new products in theyr name have a prefix, like this they're all showed in the 5th page.
I wanted to ask if there was a way to tell woocommerce to keep the alphabetical oreder but without counting the prefix
Thanks
I don't think it is directly possible. There is a workaround though:
Create a custom (post meta) field associated with the "product" post type (e.g abc_title)
Replicate the product title (without prefix) in it, on the product save hook
Use pre_get_posts action on the product page and update the sortorder field (abc_title)
For already added posts, you can write a script to replicate product titles.
Bingo!
Related
I would like to modify the behavior of upsells and cross-sells product search in the admin product edit. It should search only in product titles.
By default, it searches description as well. That’s why there are too many score, I can’t find the product what I search.
[1
I had the same problem with the frontend product finder, but I solved it with a hook. Is there any hook for upsell and cross-sell finder?
Thanks!
The search request goes to this function
https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/includes/data-stores/class-wc-product-data-store-cpt.php#L1582
There you can find a filter woocommerce_product_pre_search_products for a custom result, so basically you'll have to copy-paste the whole code below that filter line and remove a few things from line no 1651 or you can just modify the core plugin files.
However, I don't see any specific param to identify the request so this change will affect everywhere on the website where search_products is used from the data store.
For the last few days I have been wrapping my head around this but for the life of me, can't figure out a way to do this.
I have a WordPress website dedicated to different categories of products. I use Custom Post Type UI to create the product categories, ACF for custom fields for each product type and then FacetWP for the indexing and filtering part. Each category has a dedicated catalogue style page where I have certain filters from FacetWP for users to narrow down their search for a product that fits their requirements.
Everything is working well, however, my issue is that some products get discontinued and are being replaced by newer versions. Because of this, I have added a custom field for each category such as "wm_manufactured" (washing machines) that has a simple check box with "Yes". If the checkbox is ticked, then I want the product to be displayed in the catalogue.
Does anyone know how to skip products or remove them from indexing if a certain field is empty or maybe another way of doing this?
I need these product pages to still be available through a direct link because they are being ranked high on Google and I have a banner informing customers that this particular product has been discontinued and have a link to its replacement.
So I found the answer to my trouble and it was right in front of me.
When making a "Listing" template in FacetWP, there is a second tab called Query.
When I was testing the query filters, I was only putting the value that I set up on ACF, but the actual value that I had to add for the system to compare to was the exact figure from inside the database.
While ACF would have returned a "yes" for example, FacetWP was only seeing
a : 1 : { i : 0; s : 3 : "yes"; }
the value present in the database. So check the database for the exact value and don't just go based on what ACF will return.
I would like to Prevent categories from being overwritten during woocommerce csv Product upload.
When updating products useing built in woocommerce csv importer i would like to prevent existing categories from being overwritten so that product remains in existing categories and is also added to new categories.
Is there a way to do this?
Thank you
LFC
If you are uploading through the woocommerce csv upload, be sure to tick the box of "update matching products". if in your CSV you don´t have a column for your categories and you don´t map it, the category related to that product should not be affected whatsoever.
If you want to add a new product to a new category, then you should add the column category in the CSV and map it with the categories (and don´t tick the update matching products box)
If it is a product that it´s already in your page and you want to assign it a new category then you should tick the previously mentioned box and assign the category in the CSV (make sure that the category name is EXACTLY the same).
Btw i believe this kind of questions are not accepted in SO, you should always provide the steps you have tried and a code snippet if possible. Maybe this question is more fitted in a WooCommerce forum.
I added a new custom post in Wordpress and named it Products.
In admin menu in Products I have two links - All Products and New Product.
Everything works perfectly, each product has it's own permalink, fields and so on.
Question: What shall I do to have a few editable fields to be common for all products?I mean, I wish to edit a field just a single time in admin and it shall display on all product pages.
Use the Settings API.
There is no built-in way to do it at a custom post type level.
You could also define a secondary custom post type ("All Products Details") and attach it to every Product you create as a custom field on it, but then you also have to implement an automated way of setting defaults for custom fields (Here's a way to do this.).
I am using latest wp and wc and I am trying to add a form field in the frontend single product page where the user will be able to add comments which when the order is done the data will be available under woocommerce -> orders. Have anybody done that or it's not even possible because woocommerce is pretty limited for stuff like this?