Notifications
Retirer tout
Ajout case a cocher sur page commande
Forum de Support WooCommerce
2
Publications
2
Utilisateurs
0
Reactions
0
Vu
Début du sujet
Bonjour
J'ai besoin d'ajouter de manière dynamique une case a cocher sur la page commande.
Cette checkbox aura une valeur calculée et cette valeur sera ajoutée au montant total si elle est cochée.
Je dois donc aussi sauver cette valeur avec la commande et l'envoyer par email avec le reste des infos de la commande.
J'ai ce code mais il ne gère pas l'addition de la valeur de la checkox au montant total...
merci
/**
* Add checkbox field to the checkout
**/
add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');
function my_custom_checkout_field( $checkout ) {
echo ''.__('My Checkbox: ').'
';
woocommerce_form_field( 'my_checkbox', array(
'type' => 'checkbox',
'class' => array('input-checkbox'),
'label' => __('I have read and agreed.'),
'required' => true,
), $checkout->get_value( 'my_checkbox' ));
echo '';
}
/**
* Process the checkout
**/
add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process');
function my_custom_checkout_field_process() {
global $woocommerce;
// Check if set, if its not set add an error.
if (!$_POST['my_checkbox'])
$woocommerce->add_error( __('Please agree to my checkbox.') );
}
/**
* Update the order meta with field value
**/
add_action('woocommerce_checkout_update_order_meta', 'my_custom_checkout_field_update_order_meta');
function my_custom_checkout_field_update_order_meta( $order_id ) {
if ($_POST['my_checkbox']) update_post_meta( $order_id, 'My Checkbox', esc_attr($_POST['my_checkbox']));
}
Posté : 02/06/2017 10:15 am
Salut
Ca m'a l'air bien compliqué ton affaire. Je t’invite a voir avec un développeur spécialisé WP / WooCommerce
Posté : 07/06/2017 5:21 pm
Forum Information
- 10 Forums
- 7,342 Sujets
- 22.7 K Publications
- 1 En ligne
- 86.1 K Membres
Notre nouveau membre: ayoluca4291929
Dernière publication: WordPress / WooCommerce - création boutique et restaurant
Icônes du forum:
Le forum ne contient aucun message non lus
Le forum contient des messages non lus
Icônes de sujet:
Pas répondu
Repondu
Actif
Important
Épinglé
Non approuvé
Résolu
Privé
Fermé
