infrangible / m2-catalog-product-option-price
Calculates and stores the share of custom options in each cart and order item price, including tax, so other Infrangible option modules can show and process option prices separately.
Package info
github.com/infrangible-dev/m2-catalog-product-option-price
Type:magento2-module
pkg:composer/infrangible/m2-catalog-product-option-price
Requires
- php: >=8.1
- fewedev/base: ~2.4.1
- infrangible/m2-foundation: ~3.0.1
- magento/framework: ~103.0.6
- magento/module-catalog: ~104.0.0
- magento/module-directory: ~100.4.0
- magento/module-quote: ~101.2.0
- magento/module-sales: ~103.0.0
- magento/module-tax: ~100.4.0
Requires (Dev)
- infrangible/phpstan-magento: ~1.2.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Magento 2 module that calculates the prices of the custom options of products for the cart, the order and the API. Magento only adds the option prices to the price of a product; this module also keeps them separately, so that other modules can show them, for example the option prices in the cart.
Prices
- Product: when Magento calculates the final price of a product, the module stores the price of the selected
options in the data
options_price_attached(multiplied with the quantity) andoptions_price_unattached(added once per row, for example options with an own product), and the final price without options infinal_price_without_options, the base of options with a percent price. - Quote item and order item: the columns
options_price,row_options_priceand their variantsbase_*(base currency) and*_incl_taxhold the option prices per unit and per row, with and without tax. They are copied from the quote item to the order item. - Order item options: when an order is placed, each option in the product options of the item gets its
priceincluding tax; for items with a discount also theoriginal_priceand its share of thediscount. - API: the order repository adds these prices to the extension attributes
original_price,discountandpriceof the custom options of the order items, for example inGET /V1/orders/:id.
Events
| Event | Data |
|---|---|
catalog_product_get_option_price |
data: product, final_price, qty, product_option, custom_option, option_price (changeable) |
catalog_product_get_options_price |
data: product, qty, final_price, options_price_attached, options_price_unattached (changeable) |
order_item_option_price |
data: item, item_product_option_data, custom_option, original_price, discount, price (changeable) |
For example, Infrangible Catalog Product Option Product adds the prices of options with an own product as unattached price, and Infrangible Bundle Option Qty Price changes option prices by quantity.
Requirements
- Magento 2.4.6 to 2.4.9
- PHP 8.1 or newer
Installation
composer require infrangible/m2-catalog-product-option-price bin/magento module:enable Infrangible_CatalogProductOptionPrice bin/magento setup:upgrade
License
Infrangible Catalog Product Option Price is licensed under the MIT License - see the LICENSE file for details.