I made this checkbox in the checkout form of woocommerce (added in the function.php of my child theme):
add_action('woocommerce_after_checkout_billing_form', 'checkout_shipping_form_packing_addition', 20);
function checkout_shipping_form_packing_addition()
{
$domain = 'woocommerce';
echo '<tr class="packing-select">' . __('Consegna rapida?', $domain) . '<td>';
$chosen = WC()->session->get('chosen_packing');
// Add a custom checkbox field
$variable = <<<XYZ
<html>
<body>
<p style="font-size:15px; margin-top: -36px; margin-left: 23px; height:auto; text-align: center; border:1px; border-style:solid; border-color:#FF0000; padding: 5px;"><b>Consegna rapida? (+5 euro)</b></p>
</body>
</html>
XYZ;
woocommerce_form_field('chosen_packing', array(
'type' => 'checkbox',
'class' => array('form-row-wide packing'),
'label' => __($variable, 'woocommerce'),
'required' => false,
), $chosen);
echo '</td></tr>';
}
I'm trying to make it so when it's checked, the label changes to another sentence but I don't know how to do this, my knowledge of php is kinda low.
Aucun commentaire:
Enregistrer un commentaire