/** * Astra Child Theme functions and definitions * * @link https://developer.wordpress.org/themes/basics/theme-functions/ * * @package Astra Child * @since 1.0.0 */ /** * Define Constants */ define( 'CHILD_THEME_ASTRA_CHILD_VERSION', '1.0.0' ); /** * Enqueue styles */ function child_enqueue_styles() { wp_enqueue_style( 'astra-child-theme-css', get_stylesheet_directory_uri() . '/style.css', array('astra-theme-css'), CHILD_THEME_ASTRA_CHILD_VERSION, 'all' ); } // Change add to cart text on single product page add_filter( 'woocommerce_product_single_add_to_cart_text', 'woocommerce_add_to_cart_button_text_single' ); function woocommerce_add_to_cart_button_text_single() { return __( 'הוסף לעגלה', 'woocommerce' ); } // Change add to cart text on product archives page add_filter( 'woocommerce_product_add_to_cart_text', 'woocommerce_add_to_cart_button_text_archives' ); function woocommerce_add_to_cart_button_text_archives() { return __( 'הוסף לעגלה', 'woocommerce' ); } add_action( 'wp_enqueue_scripts', 'child_enqueue_styles', 15 ); /* אבחון און ליין */ add_filter( 'woocommerce_defer_transactional_emails', '__return_true' ); function wporg_replace_user_mail_from( $from_email ) { // This will give us and array with the email user and the domain // like this [ 'wordpress', 'example.tld' ] $parts = explode( '@', $from_email ); // Add our new email user, add @ again, and append the domain // This will be hello@example.tld return 'DrGavriel@' . $parts[1]; } /** * Filter the email address using str_replace() function. */ function wpdocs_custom_wp_mail_from( $original_email_address ) { // The $original_email_address value is wordpress@yourdomain.tld // So we just change 'wordpress@' to something else like 'noreply@' or etc return str_replace( 'wordpress@', 'DrGavriel@', $original_email_address ); } function custom_wp_mail_from_name( $original_email_from ) { return 'ד"ר גבריאלוב'; } add_filter( 'wp_mail_from_name', 'custom_wp_mail_from_name' ); add_filter( 'wp_mail_from', 'wpdocs_custom_wp_mail_from' ); add_filter( 'wp_mail_from', 'wporg_replace_user_mail_from' ); add_action('woocommerce_thankyou', 'create_password'); function create_password($order_id){ $order = wc_get_order( $order_id ); $items = $order->get_items(); foreach ( $items as $item ) { $product_id = $item->get_product_id(); $order_data = $order->get_data(); $order_billing_first_name = $order_data['billing']['first_name']; $order_billing_last_name = $order_data['billing']['last_name']; if ($product_id === 8640){ $existCode = get_post_meta($order_id, 'passwod_genarator', true); if($existCode) $code = $existCode; else{ $code = uniqid(); update_post_meta($order_id, 'passwod_genarator', $code); $subject = "קוד עבור אבחון באבנים"; $message ="שלום $order_billing_first_name $order_billing_last_name," ." \n\t\r"; $message .="לכניסה לעמוד אבחון, לחץ כאן: https://doctorgavrielov.com/diagnose/"." \n\t\r"; $message .="הקוד שלך הוא: "." \n\t\r"; $message .="$code"." \n\t\r"; $message .="הקוד הינו חד פעמי"." \n\t\r"; sendMailWithCode($order, $code, $subject, $message); } echo "

הקוד עבור אבחון הינו:
$code

"; echo "

לחץ כאן כדי לגלוש לדף האבחון

"; } elseif ($product_id === 12242){ $existCode = get_post_meta($order_id, 'passwod_genarator', true); if($existCode) $code = $existCode; else{ $code = uniqid(); update_post_meta($order_id, 'passwod_genarator', $code); $subject = "the code from doctorgavrielov"; $message ="hello $order_billing_first_name $order_billing_last_name," ." \n\t\r"; $message .="to enter to diagnose, please press here: https://doctorgavrielov.com/en/diagnose/"." \n\t\r"; $message .="your code is: $code"." \n\t\r"; $message .="the code is disposable"." \n\t\r"; sendMailWithCode($order, $code, $subject, $message); } echo "

the code is: $code

"; echo "

Start The Stone Diagnosis

"; } } } function sendMailWithCode($order, $code, $subject, $message){ $order_data = $order->get_data(); $to = $order_data['billing']['email']; wp_mail($to, $subject, $message ); } add_filter('manage_edit-shop_order_columns', 'add_column_code_to_shop_orders_list', 20); function add_column_code_to_shop_orders_list($columns) { $reordered_columns = array(); // Inserting columns to a specific location foreach ($columns as $key => $column) { $reordered_columns[$key] = $column; if ($key == 'order_status') { // Inserting after "Status" column $reordered_columns['passwod_genarator'] = __('Code', 'hello-elementor'); } } return $reordered_columns; } add_action('manage_shop_order_posts_custom_column', 'add_code_column_content_orders_list', 20, 2); function add_code_column_content_orders_list($column, $post_id) { if($column === "passwod_genarator"){ $my_var_one = get_post_meta($post_id, 'passwod_genarator', true); if (!empty($my_var_one)) echo $my_var_one; else echo '(no value)'; } } // Validate the the code is valid. add_action( 'elementor_pro/forms/validation', function ( $record, $ajax_handler ) { $form_name = $record->get_form_settings( 'form_name' ); $fields = $record->get_field( [ 'id' => 'passEnter', ] ); if ( empty( $fields ) ) { $fields = $record->get_field( [ 'id' => 'password_id', ] ); if ( empty( $fields ) ) return; } $passwordfield = current( $fields ); $codeInput = $passwordfield['value']; $orders = wc_get_orders( array('numberposts' => -1) ); $find = false; //Loop through each WC_Order object foreach( $orders as $order ){ $code = get_post_meta($order->get_id(), 'passwod_genarator', true); if($code !== "use" && $codeInput === $code){ $find = $order->get_id(); break; } } if(!$find){ $ajax_handler->add_error( $passwordfield['id'], 'סיסמה לא נכונה, נסה שנית' ); } else { if($form_name === "form") /* sign coda as "use" only in second form */ update_post_meta($find, 'passwod_genarator', "use"); } }, 10, 2 ); add_action( 'wp_print_scripts', 'de_script', 100 ); function de_script() { wp_dequeue_script( 'wc-cart-fragments' ); wp_dequeue_script( 'wc-checkout' ); return true; } // change the text of the add to cart button according to the language add_filter( 'woocommerce_product_add_to_cart_text', 'woocommerce_custom_single_add_to_cart_text', 99, 1 ); add_filter( 'woocommerce_product_single_add_to_cart_text', 'woocommerce_custom_single_add_to_cart_text', 99, 1 ); function woocommerce_custom_single_add_to_cart_text( $text ) { // returns the current language "Polylang" switch ( pll_current_language() ) { case 'en': return __( 'Add to Cart', 'woocommerce' ); case 'he': return __( 'הוסף לעגלה', 'woocommerce' ); } return $text; } Addictions -
Shopping Basket
Israeli new shekel
Addictions
140.00