Replies: 5 comments 8 replies
-
Will this product type include all the Core features by default? |
Beta Was this translation helpful? Give feedback.
-
Small thing: might a classname be preferable to a slug? Depending on how - $product->get_module( 'subscriptions' );
+ $product->get_module( Subscriptions_Module::class ); |
Beta Was this translation helpful? Give feedback.
-
If a module is not activated, does that prohibit interaction? For example, if a hypothetical downloads module is initially activated, and downloadable assets are added/registered, and then for some reason the module is deactivated ... can we still access the module and its methods, or would that be prohibited? |
Beta Was this translation helpful? Give feedback.
-
@daigo75 I see you left a thumbs down on this discussion and I understand you might have some concerns over backwards compatibility. The current concept attempts to remove any issues with backwards compatibility by creating a separate type (making this new modular type opt-in and not affecting other types) but still allowing classic I want to stress that this is purely exploratory at the moment and not something we would implement if it would cause issues in backwards compatibility. If you have use cases you're concerned about, it would be great to share those so we can discuss and make those cases are covered. |
Beta Was this translation helpful? Give feedback.
-
@joshuatf The use case that worries you is used here: https://brickslabs.com/create-a-customizable-ajax-add-to-cart-button-in-bricks-builder/ |
Beta Was this translation helpful? Give feedback.
-
The usage of templates in the new product editor and attempt at combining features from multiple product types into a single template have exposed some long-standing challenges in WooCommerce product types.
I previously explored the option of deprecating product types in favor of the concept of "traits." I've since opened a few more concepts to explore this option to see what problems we might face in this process. My latest concept moves towards the ideas of "modules" in #45722 as pieces of functionaity that enhance the base product.
Relevant POC PRs:
#44657
#44585
#45635
#45722
Why modules
There a few major benefits to moving away from product types:
The strategy
In the latest PR, #45722, I explore the idea of creating a new product type
WC_Product_Modular
that acts as the new base product extensible with modules. By creating a new product type, we:Implementation
This implementation keeps modules isolated and more closely follows SOLID principles. While earlier concepts explored integrating traits directly into the product class, we ultimately end up with an inconsistent interface depending on which modules are available. With this concept modules get registered on the
woocommerce_product_modules
hook:Module instances get created on each product:
Modules then can be activated, accessed, or deactivated:
Next steps
Beta Was this translation helpful? Give feedback.
All reactions