is_taxable(); $class = $extra->tax_class(); $type = $this->types->get( $extra->type ); if ( ! $type || ! $type->is_chargeable( $extra, $selection ) ) { return PriceResult::zero( $taxable, $class ); } $pricing = $type->pricing_for( $extra, $selection ); $method = $this->pricing->get( (string) ( $pricing['method'] ?? '' ) ); if ( ! $method ) { return PriceResult::zero( $taxable, $class ); } $amount = $method->calculate( $pricing, $extra, $selection, $context ); /** * Filters the extra amount as the store enters it (before conversion to net). * * @since 1.0.0 * * @param string $amount Decimal string. * @param Extra $extra Extra. * @param Selection $selection Selection. * @param Context $context Context. */ $amount = apply_filters( 'extrova_extra_price', $amount, $extra, $selection, $context ); $amount = is_scalar( $amount ) ? (float) wc_format_decimal( (string) $amount ) : 0.0; if ( $amount <= 0 ) { return PriceResult::zero( $taxable, $class ); } $is_net = $method instanceof NetAmountPricingInterface && $method->returns_net_amount( $pricing, $context ); $net = $is_net ? round( $amount, wc_get_price_decimals() ) : $this->tax->to_net( $amount, $taxable, $class, $context ); $tax = $this->tax->tax_for( $net, $taxable, $class, $context ); $display = $this->tax->display_including_tax( $context ) ? $net + $tax : $net; return new PriceResult( (string) wc_format_decimal( $net, wc_get_rounding_precision() ), $taxable, $class, Money::decimal( $display ), Money::decimal( $tax ) ); } }