Enhanced WooCommerce integration for Jankx theme with Buy Now button, sale badge percentage display, and Gutenberg blocks.
- One-click checkout functionality
- Clears cart before adding product (optional)
- AJAX-powered for smooth experience
- Fully customizable button text and styling
- Can be enabled/disabled via theme options
- Converts "Sale!" to percentage discount (e.g., "-30%")
- Multiple badge formats: percentage, amount, custom text
- Configurable minimum discount threshold
- Color customization options
- Works with WooCommerce blocks
- Buy Now Button Block: Add buy now buttons anywhere in your product templates
- Sale Badge Block: Display sale badges with flexible positioning and styling
- Dedicated WooCommerce settings page in Jankx Theme Options
- Enable/disable features globally
- Configure button text, badge format, colors, and more
- Product page settings (sticky add to cart, hide tabs)
- Shop page settings (AJAX add to cart, quick view)
This extension is bundled with Jankx theme and will be automatically loaded when WooCommerce is active.
- Go to Jankx > WooCommerce in the WordPress admin
- Enable/disable features as needed
- Configure settings for each feature
- Save changes
- Edit a page or template in the block editor
- Look for blocks in the "WooCommerce" category
- Add "Buy Now Button" or "Sale Badge" blocks
- Customize via block settings panel
The WooCommerce options page is automatically injected into:
wp-admin/admin.php?page=jankx-theme-options
extensions/woocommerce/
βββ WooCommerceExtension.php # Main extension class
βββ manifest.json # Extension manifest
βββ package.json # NPM dependencies for block building
βββ webpack.config.js # Webpack configuration for blocks
βββ src/
β βββ Admin/
β β βββ Options.php # Theme options integration
β βββ Services/
β β βββ BuyNowService.php # Buy now functionality
β β βββ SaleBadgeService.php # Sale badge logic
β βββ Adapters/
β β βββ ProductAdapterFactory.php
β β βββ WCProductAdapter.php
β β βββ WPPostAdapter.php
β β βββ ProductIdAdapter.php
β β βββ Contracts/
β β βββ ProductAdapterInterface.php
β βββ Blocks/
β βββ BlocksManager.php # Block registration
β βββ BuyNowButton/
β β βββ Block.php # Buy now block render
β βββ SaleBadge/
β βββ Block.php # Sale badge block render
βββ blocks/ # Gutenberg block source files
β βββ buy-now-button/
β β βββ block.json # Block metadata
β β βββ index.js # Block registration & edit component
β β βββ editor.scss # Editor-only styles
β β βββ style.scss # Frontend & editor styles
β β βββ build/ # Compiled block assets
β β βββ index.js
β β βββ index.asset.php
β β βββ editor.css
β β βββ style.css
β βββ sale-badge/
β βββ block.json # Block metadata
β βββ index.js # Block registration & edit component
β βββ editor.scss # Editor-only styles
β βββ style.scss # Frontend & editor styles
β βββ build/ # Compiled block assets
β βββ index.js
β βββ index.asset.php
β βββ editor.css
β βββ style.css
βββ assets/
β βββ css/
β βββ blocks-editor.css # Editor styles
βββ tests/ # Unit & integration tests
β βββ bootstrap.php
β βββ phpunit.xml # PHPUnit configuration
β βββ Unit/
β β βββ Services/
β β β βββ BuyNowServiceTest.php
β β β βββ SaleBadgeServiceTest.php
β β βββ Adapters/
β β β βββ ProductAdapterFactoryTest.php
β β β βββ ProductIdAdapterTest.php
β β β βββ WCProductAdapterTest.php
β β β βββ WPPostAdapterTest.php
β β βββ Admin/
β β βββ OptionsTest.php
β βββ Integration/
β βββ WooCommerceExtensionTest.php
βββ langs/ # Translation files
Tests use PHPUnit with configuration at tests/phpunit.xml:
cd extensions/woocommerce
phpunit --configuration tests/phpunit.xml- Create service class in
src/Services/ - Add settings in
src/Admin/Options.php - Initialize service in
WooCommerceExtension::init_services() - Write tests in
tests/
jankx/woocommerce/buy_now/enabled- Enable/disable buy now featurejankx/woocommerce/buy_now/text- Modify button textjankx/woocommerce/buy_now/text_prefix- Add prefix to button textjankx/woocommerce/buy_now/css/enabled- Enable custom CSS
jankx/woocommerce/sale_badge/enabled- Enable/disable sale badge
- WordPress 6.0+
- WooCommerce 7.0+
- Jankx Theme 2.0+
- Initial release
- Buy Now button feature
- Sale badge percentage display
- Gutenberg blocks
- Theme options integration
- Full unit test coverage
GPL-2.0-or-later