Étiqueté : 

2 sujets de 1 à 2 (sur un total de 2)
  • Auteur
    Messages
  • #3621
    picpoul
    Participant
    Points: 81 pts

    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'])); }
    depanagewp
    #3647
    Fred – WooFrance
    Maître des clés
    Points: 7,399 pts
    Certifié
    Membre 2 étoiles

    Salut

    Ca m’a l’air bien compliqué ton affaire. Je t’invite a voir avec un développeur spécialisé WP / WooCommerce

    depanagewp
2 sujets de 1 à 2 (sur un total de 2)
  • Vous devez être connecté pour répondre à ce sujet.