Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save somewherewarm-snippets/2b01ab39b9f99bace2cc6f2841296d4b to your computer and use it in GitHub Desktop.
Save somewherewarm-snippets/2b01ab39b9f99bace2cc6f2841296d4b to your computer and use it in GitHub Desktop.
<?php
/**
* Plugin Name: WooCommerce Composite Products
* Plugin URI: https://woocommerce.com/products/composite-products/
* Description: Use this snippet to calculate a components' Relative Price based on the selected option
* Version: 1.0
* Author: WooCommerce
* Author URI: https://woocommerce.com/
* Developer: Manos Psychogyiopoulos
*
* Requires at least: 4.1
* Tested up to: 5.3
*
* Copyright: © 2021 Automattic.
* License: GNU General Public License v3.0
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
add_filter( 'woocommerce_composite_add_to_cart_form_settings', 'disable_relative_to_default', 10, 2 );
function disable_relative_to_default( $settings, $composite ) {
foreach ( $settings[ 'price_display_data' ] as $component => $value ) {
if ( 'relative' === $settings[ 'price_display_data' ][ $component ][ 'format' ] ) {
$settings[ 'price_display_data' ][ $component ][ 'is_relative_to_default' ] = 'no';
}
}
return $settings;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment