Overview

The plugin's namespace is johnhenry\bundlebuilder. Access the plugin instance via BundleBuilder::getInstance().

Element

elements\Bundle

A purchasable element (extends craft\commerce\base\Purchasable).

use johnhenry\bundlebuilder\elements\Bundle;

$bundles = Bundle::find()->type('bundles')->all();

Notable members:

MemberDescription
getType(): BundleType The bundle's type.
getProducts(): BundleProduct[] The bundle's components (product + qty).
getIsAvailable(): bool Post/expiry window + component stock check.
populateLineItem(LineItem) Resolves chosen variants, writes options + snapshot, validates stock.
afterOrderComplete(Order, LineItem) Decrements component variant inventory.
getTaxCategoryId(): int Returns the apportioned category for multiple supply bundles.

elements\db\BundleQuery

Adds type(), typeId(), postDate() and expiryDate() params on top of the standard purchasable query.

Models

  • models\BundleType: a bundle type (field layout, formats, site settings, preview targets, tax treatment).
  • models\BundleTypeSite: per-site URL settings.
  • models\BundleProduct: a component (productId, qty, sortOrder).

Enums

  • enums\PricingStrategy: Fixed, Automatic.
  • enums\DiscountType: Percentage, Flat.
  • enums\TaxTreatment: Composite, Multiple.

Twig variable

craft.bundleBuildervariables\BundleBuilderVariable (bundles(), getBundlesForProduct()).

See Services for the service layer.