/* 
Theme Name: Hello Elementor Child
Theme URI: https://github.com/elementor/hello-theme-child/
Description: Hello Elementor Child is a child theme of Hello Elementor, created by Elementor team
Author: Elementor Team
Author URI: https://elementor.com/
Template: hello-elementor
Version: 2.0.0
Text Domain: hello-elementor-child
License: GNU General Public License v3 or later.
License URI: https://www.gnu.org/licenses/gpl-3.0.html
Tags: flexible-header, custom-colors, custom-menu, custom-logo, editor-style, featured-images, rtl-language-support, threaded-comments, translation-ready
*/

/* Add your custom styles here */






/*---------------------------------------------
 *this function handles the "do you need extra services?" notes on the checkout page  (by menna) */


// 1. Add the checkbox with English label at the end of Checkout
add_action( 'woocommerce_review_order_before_submit', 'add_workshop_extra_service_checkbox' );
function add_workshop_extra_service_checkbox() {
    echo '<div style="margin: 20px 0; padding: 10px; background: #f9f9f9; border-radius: 5px;">';
    
    woocommerce_form_field( 'workshop_extra_service', array(
        'type'          => 'checkbox',
        'class'         => array('form-row-wide'),
        'label'         => 'Do you need extra service in the workshop?', // الجملة بالإنجليزي
        'required'      => false,
    ));

    echo '</div>';
}

// 2. Save the value to the order database
add_action( 'woocommerce_checkout_update_order_meta', 'save_workshop_service_to_order' );
function save_workshop_service_to_order( $order_id ) {
    if ( ! empty( $_POST['workshop_extra_service'] ) ) {
        update_post_meta( $order_id, 'Extra Workshop Service', 'Yes, requested');
    }
}