facebook-for-woocommerce
facebook-for-woocommerce copied to clipboard
Add support for Mix and Match product price
Feature requests
I have a customer using Mix and Match to group chocolates together. The price of the box depends on the price of the optional products. But the price showing up at Facebook is $0 (which is the base price of the container itself).
I see there's explicitly compatibility for Product Bundles and Composites and since they are very similar to Mix and Match, I was hoping you might add Mix and Match in there too.
An additional elseif should look like this:
} elseif ( $product->is_type( 'mix-and-match' ) && $product->is_priced_per_product() ) {
// If product is Mix and Match product with individually priced items, we rely on their pricing.
$price = wc_get_price_to_display( $product, [ 'price' => $product->get_container_price() ] );
}
Hey @helgatheviking 👋 Hope things are going well with you and thanks for opening the issue. We won't get a chance to prioritize working on this but if you happen to whip up a PR there will be a better chance to get the compatibility added. Thanks!
Hi Jason! I'm hanging in there... the brain is not really cooperating with this code stuff at the moment, but I'm trying my best.
PR for mix and match incoming. May be worth checking with @franticpsyx if the Composite/Bundles compat could be unified to the following:
} elseif ( $product->is_type( 'composite' ) ) {
$price = wc_get_price_to_display( $product, [ 'price' => $product->get_composite_price() ] );
} elseif ( $product->is_type( 'bundle' ) ) {
// If product is a product bundle with individually priced items, we rely on their pricing
$price = wc_get_price_to_display( $product, [ 'price' => $product->get_bundle_price() ] );
}
if so, if so I can push that commit to my PR as well.
@helgatheviking just one comment --
You don't need to wrap those function calls in wc_get_price_to_display, because get_composite_price and get_bundle_price already include arguments for retrieving the price depending on how the store is displaying prices (incl/excl tax).
So, to get the "display" catalog price of a Product Bundle, you'd call
->get_bundle_price( 'min', true )
and to get the "display" regular price:
->get_bundle_regular_price( 'min', true )
Going via wc_get_price_to_display can lead to incorrect tax calculations, as a bundle may contain multiple products with different tax rates -- this is properly taken into account in get_bundle/composite[regular]_price( 'min', true ).
Awesome feedback... thanks @franticpsyx I've included that in my PR now: https://github.com/facebookincubator/facebook-for-woocommerce/pull/1800/commits/cd8d2413b6fa7764993025c446d0dca8569f12f6
Now I just need a version check as my equivalent get_container_price() won't be out until 2.0.
@jconroy think this could get a look? Would love to have it in place for when I do finish Mix and Match 2.0.
Thanks for the nudge @helgatheviking - we'll try to get a review of this before the next release (2.6) and proceed from there.