The agency I work for are trying to get a client's website to auto-select the first option on the maintenance packages for their products.
Currently, we are using an if statement within a foreach.
The code below is the script we are currently using:
Woocommerce Product Add-ons - Auto-select first option
Currently, we are using an if statement within a foreach.
The code below is the script we are currently using:
PHP:
<?php foreach ( $addon['options'] as $i => $option ) :
$price = $option['price'] > 0 ? '(' . wc_price( get_product_addon_price_for_display( $option['price'] ) ) . ')' : '';
$current_value = 0;...
$price = $option['price'] > 0 ? '(' . wc_price( get_product_addon_price_for_display( $option['price'] ) ) . ')' : '';
$current_value = 0;...