Skip to content

jankx/woocommerce-extension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

WooCommerce Extension for Jankx

Enhanced WooCommerce integration for Jankx theme with Buy Now button, sale badge percentage display, and Gutenberg blocks.

Features

πŸ›’ Buy Now Button

  • 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

🏷️ Sale Badge

  • 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

🧩 Gutenberg 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

βš™οΈ Theme Options Integration

  • 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)

Installation

This extension is bundled with Jankx theme and will be automatically loaded when WooCommerce is active.

Usage

Enabling Features

  1. Go to Jankx > WooCommerce in the WordPress admin
  2. Enable/disable features as needed
  3. Configure settings for each feature
  4. Save changes

Using Gutenberg Blocks

  1. Edit a page or template in the block editor
  2. Look for blocks in the "WooCommerce" category
  3. Add "Buy Now Button" or "Sale Badge" blocks
  4. Customize via block settings panel

Theme Options Location

The WooCommerce options page is automatically injected into: wp-admin/admin.php?page=jankx-theme-options

File Structure

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

Development

Running Tests

Tests use PHPUnit with configuration at tests/phpunit.xml:

cd extensions/woocommerce
phpunit --configuration tests/phpunit.xml

Adding New Features

  1. Create service class in src/Services/
  2. Add settings in src/Admin/Options.php
  3. Initialize service in WooCommerceExtension::init_services()
  4. Write tests in tests/

Filters & Actions

Buy Now

  • jankx/woocommerce/buy_now/enabled - Enable/disable buy now feature
  • jankx/woocommerce/buy_now/text - Modify button text
  • jankx/woocommerce/buy_now/text_prefix - Add prefix to button text
  • jankx/woocommerce/buy_now/css/enabled - Enable custom CSS

Sale Badge

  • jankx/woocommerce/sale_badge/enabled - Enable/disable sale badge

Requirements

  • WordPress 6.0+
  • WooCommerce 7.0+
  • Jankx Theme 2.0+

Changelog

1.0.0

  • Initial release
  • Buy Now button feature
  • Sale badge percentage display
  • Gutenberg blocks
  • Theme options integration
  • Full unit test coverage

License

GPL-2.0-or-later

About

WooCommerce Extension for Jankx Theme

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors