*edit* making this visible for any users with WCK
OK I can see the problem here
WCK is storing the meta data in a non standard way…
Basically, if you had a price meta field, you would expect the value of this field to only contain the price… but it does not..
Eg… Woocommerce adds a price custom field to all products, the data as an example would look like this if you did a var_dump
like we did for your site:
["_price"]=>
array(1) {
[0]=>
string(1) "10"
}
This means the price was set to 10.
What WCK is doing is this:
["rosstest"]=>
array(1) {
[0]=>
string(40) "a:1:{i:0;a:1:{s:8:"rosstest";s:2:"10";}}"
}
Notice in the first example we have
string(1) "10"
And in the test field I made for your site:
string(40) "a:1:{i:0;a:1:{s:8:"rosstest";s:2:"10";}}"
It is storing a lot of extra information in the field, such as the name as well as the value (and it’s serialising the data) – this makes it unsearchable – you can’t even use WP_Query to create a query on the meta data generated by that plugin – I personally think this is a very bad implementation – but I guess they may have solutions for this in their docs.
In this case, I would recommend to use the Advanced Custom Fields plugin – I’ve used it many times, and it stores meta data cleanly and doesn’t stop it from being searchable – I’m sure there are plenty of others, it just seems like WCK is making life difficult!
Hope that makes sense.
Thanks
Yeah pretty much – but the thing is, the example I’m giving is for a theme that works with WooCommerce – and this guidline is really a rough guide to duplicating your shop page with woocommerce for use with S&F results…
WooCommerce has a lot of its own template files –
http://docs.woothemes.com/document/template-structure/
And usually the one for your shop is called product-archive.php
– so I would look at this file,
What I did was –
Duplicate page.php – call it search-filter.php – edit this.
Then, in the part where you have The Loop –
<?php
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
//
// Post Content here
//
} // end while
} // end if
?>
I would replace this with the code from product-archive.php
– the parts from <!-- #main Starts -->
to <!-- /#main -->
– like the code I pasted above.
I’m afraid this is a pretty loose guideline and if your not using WooCommerce it won’t work, its also completely dependent on how your theme is setup – you might not see the code I mention above for example – you’ll have to play around with this, and possible reorganise some of the html to fit in with your theme properly.
Thanks
Hey Khao
You’re right about the taxonomies – I believe taxonomies should not have spaces in their name if we are using WordPress conventions.
The grid like you mention is a layout that comes with woocommerce – that we must take the code from –
http://demo2.woothemes.com/?name=mystile
To create the search results screen I created a new template (based on page.php), then I replaced the loop with code from woocommerce – templates/product-archive.php
which has the grid template:
<div id="content" class="col-full">
<!-- #main Starts -->
<div id="main" class="col-left">
<?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?>
<h1 class="page-title"><?php woocommerce_page_title(); ?></h1>
<?php endif; ?>
<?php do_action( 'woocommerce_archive_description' ); ?>
<?php if ( have_posts() ) : ?>
<?php
/**
* woocommerce_before_shop_loop hook
*
* @hooked woocommerce_result_count - 20
* @hooked woocommerce_catalog_ordering - 30
*/
do_action( 'woocommerce_before_shop_loop' );
?>
<?php woocommerce_product_loop_start(); ?>
<?php woocommerce_product_subcategories(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php wc_get_template_part( 'content', 'product' ); ?>
<?php endwhile; // end of the loop. ?>
<?php woocommerce_product_loop_end(); ?>
<?php
/**
* woocommerce_after_shop_loop hook
*
* @hooked woocommerce_pagination - 10
*/
do_action( 'woocommerce_after_shop_loop' );
?>
<?php elseif ( ! woocommerce_product_subcategories( array( 'before' => woocommerce_product_loop_start( false ), 'after' => woocommerce_product_loop_end( false ) ) ) ) : ?>
<?php wc_get_template( 'loop/no-products-found.php' ); ?>
<?php endif; ?>
</div><!-- /#main -->
The rest you will need to have a play with to get nice integration.
Thanks
AnonymousInactive
Ok, so I figured out my problems with filtering using AND with 2 taxonomies.
– custom taxonomies don’t work well with spaces in their names and slugs (or capital letters too…?). It’s filtering perfectly right now.
– also shouldn’t use categories and custom taxonomies together, otherwise the product count is wrong.
So my only problem is showing the results in grid like your demo woocommerce shop http://demo.designsandcode.com/sfpro-woo-mystile/product-search/
How is that done? I can’t seem to find the solution in support threads. Hope you can help. Thanks.
AnonymousInactive
I’m trying to use this plugin for my woocommerce shop and wish to have something like this http://demo.designsandcode.com/sfpro-woo-mystile/product-search/
1. I’ve getting help from https://support.searchandfilter.com/forums/topic/and-or/ and https://support.searchandfilter.com/forums/topic/and-filtering-not-working/#post-9913 but pretty much stuck.
Basically, I’m trying to filter for certain products that has two custom taxonomies.
I used CPT UI plugin to add 2 new taxonomies “product types” and “model types”. I went into one product post and added new category for both of of them. “product types” – “leather” , “model types” – “iphone 6”
I created a new search form with 2 new fields,
Taxonomy: product types (change to OR)
Taxonomy: Model types (change to OR)
Change “field relationships” to AND in “tags, Categories& Taxonomies”
Then, I add shortcode to page and result shortcode to page widget. When I click on only “leather” or “iphone 6”, “no results found” appear. Same if both selected.
2. I tested using “product categories” in the form, and it returns results in posts form, unlike the shop grid results here http://demo.designsandcode.com/sfpro-woo-mystile/product-search/
How do I do that?
Hey Nikolasa
Thanks for the kind words – yes I see the problem you have on your site – the problem is you want multiple fields for a single taxonomy (category – a category is basically the same a taxonomy)…
However – 1 field = 1 taxonomy. This is a fairly common issue with a fairly simple fix (depends on how much content you have).
Basically you need to set up a custom taxonomy for each of your filters above – please see this similar post with some recommendations – https://support.searchandfilter.com/forums/topic/and-filtering-not-working/#post-9913 – also note the plugin I recommend doesn’t play so well with WooCommerce -there is another suggestion further down link 🙂
Thanks
Ah cool, yes I think this is what you must do – woocommerce must have a way to get the current currency, and of course then you should conditionally load custom search forms depending on this setting.
RE the multi language guide – this is something I’ve been meaning to add for a while and your post spurred me on to write it 😉
Thanks
AnonymousInactive
Hello Ross, thanks for your quick response!
anyway, i am on the other situation, using Woocommerce with wpml with one language, two currency.
so, i have only a currency switcher, and the website is in english.
http://wpml.org/documentation/related-projects/woocommerce-multilingual/multi-currency-support-woocommerce/
when you switch from one currency to other, the price on products change with correct symbol, and with default for example, woo commerce price filter widget, it change the currency.
in this case, where your plugin allow to insert the symbol, the only way i m thinking is with some way of conditional widget, where i show one or the other widget, accordly to currency, and i build two search form, identical, with the currency set up on each one. I only can-t find around if wpml give this kind of support of checking condition for currency on widget, like it do for language like this
ICL_LANGUAGE_CODE == ‘en’
http://wpml.org/2011/03/howto-display-different-widgets-per-language/
Thanks for the guide for multi language form!
g
Hey Giovanni
I’m not too familiar with multiple currencies WooCommerce however I have done extensive testing with WPML.
If you are using a single currency per language then it would be quite straight forward to set up I think.
In WPML head to – Translation Management -> Multilingual Content Setup -> Custom Posts
enable translations for “Search & Filter”.
Then in the Search & Filter admin screen, you will find your existing search forms in your default language. Edit a Search Form.
On the right in the Language meta box, you should duplicate the form for each language you need it in. Then, edit these translations and make sure you select “translate independently”.
Now you can go in and change all the text in the search form, including the currency symbol for each language.
The only drawback is that the translations are no longer synced with the primary language, so if you wish add or remove fields from the UI for example, you must do so to each form manually.
Thanks
AnonymousInactive
Hello,
the filter work great with hierarchical attribute on woocommerce, thanks, only asking if there is a way to display currency symbol that reflect the current currency that a user choose? (i m talking about wpml with multi currency support, that with the woo commerce filter, when a user change currency the symbol also change)
i was thinking on building two filter, one with the price slider and one symbol, and the other with another, and with some condition display one or the other widget based on current currency.
Hope i explain in some way, well
thanks!
g