superspeedyplugins / issue-tracker

Submit bugs and feature requests for any of our plugins
0 stars 0 forks source link

SSF | Compatibility with Woo Product Bundles plugin #74

Open bhavkaka opened 5 months ago

bhavkaka commented 5 months ago

Is your feature request related to a problem? Please describe. When creating bundle product using Woo's official product bundle plugin, instead of using the default '_stock_status' meta key, it introduces a new meta key to maintain stock status i.e. '_wc_pb_bundled_items_stock_status'.

The new meta key stores the similar values as the default meta key, such as 'instock' and 'outofstock'.

The plugin uses combination of both of the meta keys to represent stock status in the frontend. The below matrix represents the frontend stock status based on the database value of the two meta keys.

Possible values for _stock_status: inorder, outofstock, onbackorder Possible values for _wc_pb_bundled_items_stock_status: inorder, outofstock

_stock_status _wc_pb_bundled_items_stock_status frontend status
instock instock instock
instock outofstock outofstock
outofstock instock outofstock
outofstock outofstock outofstock
onbackorder instock instock
onbackorder outofstock outofstock

Since SSF is not aware about the new meta key and for bundled product '_stock_status' always has to be 'instock', the filter results in frontend also includes out of stock bundled products.

Describe the solution you'd like Have SSF be aware about the new meta key to have a functioning stock status filter when using Woo Product Bundles plugin.

dhilditch commented 4 months ago

@voodoo911 this is related to the stock control options you added recently for backorders. You did a great job here, but we have a new feature request to be able to handle an additional metakey coming from WooCommerce Product Bundles plugin.

If you need a copy of that plugin, DM me and I can send you a copy.

You can see in the feature description above how this should behave, so we need an extra check in the code that builds object ancestors and the code that keeps object ancestors maintained.

You can tell if a product is a bundle by checking if it is in the 'bundle' term under the 'product_type' taxonomy.

select * from wp_term_taxonomy tt inner join wp_terms t on tt.term_id = t.term_id where taxonomy = 'product_type';

bhavkaka commented 4 months ago

Yup, that is the correct plugin.

voodoo911 commented 4 months ago

@bhavkaka Hello, I added you in discord. I have a question about your statuses table - how do you changed _wc_pb_bundled_items_stock_status ? As I see in product settings we can manage stock only on product level, and as I see based on testing result _stock_status is respected. Can you pls clear that part for me ? Tnx

bhavkaka commented 2 months ago

Didn't see your invite. I tried sending you invite on my end.

Little explainer: When you setup a product as bundle, you have to mark it as in stock in the backend and uncheck track inventory option. Only then the stock of the bundle product is calculated dynamically based on the underlying bundled item stock, and that dynamic value affects _wc_pb_bundled_items_stock_status.

So, if the dynamically calculated stock is zero then _wc_pb_bundled_items_stock_status will be outofstock but _stock_status for the same product will always be instock due the above two options.

Since SSF only respects _stock_status, the search result also shows (_wc_pb_bundled_items_stock_status, outofstock) products as well.

Drop me an invite again on Discord if that helps.