We want to have a seperate page for DISCOUNTS/DEALS (basically for products that have discounts or some kind of deals applied on them - we do that through b2bking dynamic rules or offers)
Our thinking is that we would like to create a filter for discounted/onsale items using the FileEverything Pro plugin in the shop archive. However, the _sale_price option isn't suitable for our setup, as we manage discounts through B2BKing's dynamic rules.
Another option is to create a shortcode to display discounted items separately from the default shop archive (but this would exclude the filtering option I think, but maybe I could get it to work)
Could you assist us in targeting the right meta query for discounted or on-sale items? or provide some kind of solution for our goal?
I understand you're looking to create a dedicated page or filter for products that have discounts applied through B2BKing's dynamic rules.
Unfortunately, there's no specific metadata that can be queried directly since our dynamic rules work through a cached lookup system rather than setting product meta values. The plugin uses WooCommerce filters like "woocommerce_product_is_on_sale" or "woocommerce_product_get_sale_price" to modify product prices dynamically.
1. If FileEverything Pro has a general option to filter based on "on sale" products, that should work with our dynamic rules since we hook into WooCommerce's sale status.
2. Alternatively, I think you could create a separate page using the WooCommerce products shortcode to display discounted items:
Thanks for providing those additional details and for testing this out. I've looked into the issue and did some testing on the site.
You're right - the [products] shortcode with the on_sale parameter isn't working as expected. After investigating the WooCommerce code, I found that they use direct database queries for performance optimization, which means filters like "is_on_sale" don't have the expected effect.
I can see two potential solutions here:
1. I could create a custom shortcode specifically designed to display products that have B2BKing discounts applied to them.
2. Alternatively, I could work on a shortcode that shows all on-sale products (it will query products in a regular, less performance-optimized way).
Before proceeding, I'd like to know: - Would you be interested in using a custom shortcode for on-sale products? - Or are you primarily trying to make this work with the FilterEverything plugin? If you're more interested in that approach, I can try to go over the code of that plugin to see if I can find anything useful.
For us, best scenario would be both options, to have that flexibility and ability to display on sale products however we want, according to the context and situation.
If we neee to choose one, let's go with the shortcode route.
But keep in mind that correct usage in filters (of on sale filter) is pretty common in e-commerce, so it would be beneficial to have a confirmed way for one of the popular filter plugins (filtereverything pro) to display it. (Of course this requires more in-depth look into how the plugin works)
If I could assist in any way, I would, but I am really not that knowledgeble 😅
This shortcode should display all on sale items, whether that on sale status is created via rules or another way. To test it I've created a page here https://www.nauja.barexitaliana.lt/on-sale-items which appears to work in my tests.
Zoomed out display:
Regarding filters plugins and this issue in general: Our plugin already modifies the 'woocommerce_product_is_on_sale' hook, and thus functions such as $product->is_on_sale() should return the correct values. If a filters plugin can work that way or has an option to work that way, it will work with B2BKing's discounts as well.
I understand the perspective of the filters plugin devs, as getting that data directly from the database is more efficient, but on our end we also do not have any way to set that directly in the db.
Filters plugins may have an option, or may have some "ajax" option to get the live status of products, but I do not have specific info - it would be best to ask the filters' plugin teams about this.
Hello,
We want to have a seperate page for DISCOUNTS/DEALS (basically for products that have discounts or some kind of deals applied on them - we do that through b2bking dynamic rules or offers)
Our thinking is that we would like to create a filter for discounted/onsale items using the FileEverything Pro plugin in the shop archive. However, the _sale_price option isn't suitable for our setup, as we manage discounts through B2BKing's dynamic rules.
Another option is to create a shortcode to display discounted items separately from the default shop archive (but this would exclude the filtering option I think, but maybe I could get it to work)
Could you assist us in targeting the right meta query for discounted or on-sale items? or provide some kind of solution for our goal?
Thank you!
Hi Dovydas,
I understand you're looking to create a dedicated page or filter for products that have discounts applied through B2BKing's dynamic rules.
Unfortunately, there's no specific metadata that can be queried directly since our dynamic rules work through a cached lookup system rather than setting product meta values. The plugin uses WooCommerce filters like "woocommerce_product_is_on_sale" or "woocommerce_product_get_sale_price" to modify product prices dynamically.
1. If FileEverything Pro has a general option to filter based on "on sale" products, that should work with our dynamic rules since we hook into WooCommerce's sale status.
2. Alternatively, I think you could create a separate page using the WooCommerce products shortcode to display discounted items:
[products limit="4" columns="4" orderby="popularity" on_sale="true"]
This would show products that are marked as "on sale" through our dynamic rules.
Kind regards,
Stefan
Hi Dovydas,
Thanks for providing those additional details and for testing this out. I've looked into the issue and did some testing on the site.
You're right - the [products] shortcode with the on_sale parameter isn't working as expected. After investigating the WooCommerce code, I found that they use direct database queries for performance optimization, which means filters like "is_on_sale" don't have the expected effect.
I can see two potential solutions here:
1. I could create a custom shortcode specifically designed to display products that have B2BKing discounts applied to them.
2. Alternatively, I could work on a shortcode that shows all on-sale products (it will query products in a regular, less performance-optimized way).
Before proceeding, I'd like to know:
- Would you be interested in using a custom shortcode for on-sale products?
- Or are you primarily trying to make this work with the FilterEverything plugin? If you're more interested in that approach, I can try to go over the code of that plugin to see if I can find anything useful.
Kind regards,
Stefan
Hello,
Glad to hear the solution is possible.
For us, best scenario would be both options, to have that flexibility and ability to display on sale products however we want, according to the context and situation.
If we neee to choose one, let's go with the shortcode route.
But keep in mind that correct usage in filters (of on sale filter) is pretty common in e-commerce, so it would be beneficial to have a confirmed way for one of the popular filter plugins (filtereverything pro) to display it. (Of course this requires more in-depth look into how the plugin works)
If I could assist in any way, I would, but I am really not that knowledgeble 😅
Hello,
I haven't gotten any response from you yet.
Best Regards
Hi again,
I looked into that and added a snippet to your site here https://www.nauja.barexitaliana.lt/wp-admin/admin.php?page=wpcode-snippet-manager&snippet_id=2193 that creates a [b2bking_onsale] shortcode (code for future reference https://pastecode.io/s/7sprdm75 )
This shortcode should display all on sale items, whether that on sale status is created via rules or another way. To test it I've created a page here https://www.nauja.barexitaliana.lt/on-sale-items which appears to work in my tests.
Zoomed out display:
Regarding filters plugins and this issue in general: Our plugin already modifies the 'woocommerce_product_is_on_sale' hook, and thus functions such as $product->is_on_sale() should return the correct values. If a filters plugin can work that way or has an option to work that way, it will work with B2BKing's discounts as well.
I understand the perspective of the filters plugin devs, as getting that data directly from the database is more efficient, but on our end we also do not have any way to set that directly in the db.
Filters plugins may have an option, or may have some "ajax" option to get the live status of products, but I do not have specific info - it would be best to ask the filters' plugin teams about this.