customer->get_shipping_country(); if ( !empty( $country ) ) { $all_countries = WC()->countries->get_countries(); return sprintf( "We don't ship to %s in this store, please change the actual store in the footer section.", $all_countries[ $country ] ); } return "Change store."; } // Genera shortcode free-shipping [rey_shipping_bar] add_shortcode( 'rey_shipping_bar', function(){ if( function_exists('reycore__get_module') && ($fb = reycore__get_module('mini-cart-shipping-bar')) ){ $fb->enqueue_scripts(); $fb->shipping_bar(); } }); // Rename status completed to Shipped add_filter( 'wc_order_statuses', 'wc_renaming_order_status' ); function wc_renaming_order_status( $order_statuses ) { foreach ( $order_statuses as $key => $status ) { if ( 'wc-completed' === $key ) $order_statuses['wc-completed'] = _x( 'Shipped', 'Order status', 'woocommerce' ); } return $order_statuses; } //Añadir Important information despues del boton de pago add_action( 'woocommerce_review_order_before_submit', 'add_after_checkout_button' ); function add_after_checkout_button() { echo '
'; } //disable search bar for reviews function my_cr_ajaxreviews_show_search( $show_search ) { return false; } add_filter( 'cr_ajaxreviews_show_search', 'my_cr_ajaxreviews_show_search', 10, 1 ); //change position price single product remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 25 ); //Add Breadcrumbs //codigo en el header del tema padre /**
'country', 'class' => array('chzn-drop'), 'label' => __('Country'), 'placeholder' => __('Choose your country.'), 'required' => true, 'clear' => true, 'default' => 'BE' )); ?> add( 'billing_first_name_error', __( 'Error: First name is required!', 'woocommerce' ) ); } if ( isset( $_POST['billing_last_name'] ) && empty( $_POST['billing_last_name'] ) ) { $errors->add( 'billing_last_name_error', __( 'Error: Last name is required!.', 'woocommerce' ) ); } if ( isset( $_POST['billing_phone'] ) && empty( $_POST['billing_phone'] ) ) { $errors->add( 'billing_phone_error', __( 'Error: Phone is required!.', 'woocommerce' ) ); } if ( isset( $_POST['billing_country'] ) && empty( $_POST['billing_country'] ) ) { $errors->add( 'billing_country_error', __( 'Error: Country is required!.', 'woocommerce' ) ); } return $errors; } /////////////////////////////// // 3. SAVE FIELDS add_action( 'woocommerce_created_customer', 'bbloomer_save_name_fields' ); function bbloomer_save_name_fields( $customer_id ) { if ( isset( $_POST['billing_first_name'] ) ) { update_user_meta( $customer_id, 'billing_first_name', sanitize_text_field( $_POST['billing_first_name'] ) ); update_user_meta( $customer_id, 'first_name', sanitize_text_field($_POST['billing_first_name']) ); } if ( isset( $_POST['billing_last_name'] ) ) { update_user_meta( $customer_id, 'billing_last_name', sanitize_text_field( $_POST['billing_last_name'] ) ); update_user_meta( $customer_id, 'last_name', sanitize_text_field($_POST['billing_last_name']) ); } if ( isset( $_POST['billing_phone'] ) ) { update_user_meta( $customer_id, 'billing_phone', sanitize_text_field( $_POST['billing_phone'] ) ); update_user_meta( $customer_id, 'phone', sanitize_text_field($_POST['billing_phone']) ); } if ( isset( $_POST['billing_country'] ) ) { update_user_meta( $customer_id, 'billing_country', sanitize_text_field( $_POST['billing_country'] ) ); update_user_meta( $customer_id, 'country', sanitize_text_field($_POST['billing_country']) ); } } /*Agregar mensaje en Checkout y Mini-cart*/ function agregar_mensaje_al_mini_cart() { ?> get_id() ) ) { echo 'Every second pair of Classics 50% off'; } } /** Excluir la categoría "Classics" de todos los cupones */ function exclude_classics_from_coupons( $excluded_categories ) { // Comprobar si estamos en el área de administración y si el usuario actual es un administrador if ( is_admin() && current_user_can( 'manage_woocommerce' ) ) { // No excluir la categoría "Classics" para los administradores return $excluded_categories; } // Obtener el ID de la categoría "Classics" $classics_category_id = get_term_by( 'slug', 'classics', 'product_cat' )->term_id; // Añadir el ID de la categoría "Classics" a la lista de categorías excluidas $excluded_categories[] = $classics_category_id; return $excluded_categories; } add_filter( 'woocommerce_coupon_get_excluded_product_categories', 'exclude_classics_from_coupons' ); /*traducciones manuales*/ // function custom_text_replace( $translated_text, $untranslated_text, $domain ) { // if ( function_exists( 'weglot_get_current_language' ) ) { // $currentLang = weglot_get_current_language(); // if ( $currentLang == "fr" ) { // switch ( $untranslated_text ) { // case 'Clear': // $translated_text = __( 'Clair', $domain ); // break; // case 'Add to cart': // $translated_text = __( 'Ajouter au panier', $domain ); // break; // default: // $translated_text = $untranslated_text; // break; // } // } else { // $translated_text = $untranslated_text; // } // } // return $translated_text; // } // add_filter( 'gettext', 'custom_text_replace', 20, 3 ); // function mm_add_hreflang_attribute() { // $currentLang = function_exists( 'weglot_get_current_language' ) ? weglot_get_current_language() : ''; // $current_url = get_permalink(); // $path = parse_url( $current_url, PHP_URL_PATH ); // $path = preg_replace( '/\/(fr|es)\//', '/', $path ); // if ( $currentLang == "fr" ) { // echo ' // // // // // // // // '; // } else { // echo ' // // // // // // // // '; // } // } // add_action( 'wp_head', 'mm_add_hreflang_attribute', 1 ); // function prefix_weglot_render_dom( $dom ) { // if ( function_exists( 'weglot_get_current_language' ) ) { // $currentLang = weglot_get_current_language(); // if ( $currentLang == "fr" ) { // $new_lang = 'fr-CA'; // $dom = str_replace( 'lang="fr"', 'lang="' . $new_lang . '"', $dom ); // } else { // $lang = get_bloginfo( 'language' ); // $new_lang = 'en-CA'; // $dom = str_replace( 'lang="' . $lang . '"', 'lang="' . $new_lang . '"', $dom ); // } // } // return $dom; // } // add_filter( 'weglot_render_dom', 'prefix_weglot_render_dom' ); // Eliminar el atributo nofollow de los enlaces de productos add_filter( 'woocommerce_loop_add_to_cart_args', 'add_to_cart_args_remove_nofollow' ); function add_to_cart_args_remove_nofollow( $args ) { unset($args['attributes']['rel']); return $args; } /*Sesion actual para pasar email a Update Info*/ add_action('wp_ajax_get_current_user_info', 'get_current_user_info'); add_action('wp_ajax_nopriv_get_current_user_info', 'get_current_user_info'); function get_current_user_info() { $current_user = wp_get_current_user(); echo json_encode(array('user_email' => $current_user->user_email)); wp_die(); } /*Establece la cantidad de productos por página*/ add_filter('loop_shop_per_page', 'custom_products_per_page', 20); function custom_products_per_page($products) { $products = 18; return $products; } /** Desactivar cupones add_filter('woocommerce_coupons_enabled', 'deshabilitar_cupones_front'); function deshabilitar_cupones_front($enabled) { if (is_admin()) { return true; } else { return false; } } // agregar mensaje sobre los cupones add_action( 'woocommerce_before_checkout_form', 'wnd_checkout_code', 10 ); function wnd_checkout_code( ) { echo '*Discount codes not applicable on Sale items*'; }*/ /************ Condicionales Cover Category ************/ add_filter('reycore/elementor/hide_element/pump_show_title', function( $status, $element ){ $category = get_queried_object(); if ($category && is_a($category, 'WP_Term') && $category->taxonomy === 'product_cat') { $category_id = $category->term_id; $show_title = get_field('show_title', 'product_cat_' . $category_id); if ($show_title!=1) { return true; // Ocultar este elemento } } return $status; }, 10, 2); add_filter('reycore/elementor/hide_element/pump_show_second_title', function( $status, $element ){ $category = get_queried_object(); if ($category && is_a($category, 'WP_Term') && $category->taxonomy === 'product_cat') { $category_id = $category->term_id; $show_title = get_field('show_title', 'product_cat_' . $category_id); if ($show_title==1) { return true; // Ocultar este elemento } } return $status; }, 10, 2); add_filter('reycore/elementor/hide_element/pump_show_category', function( $status, $element ){ $category = get_queried_object(); if ($category && is_a($category, 'WP_Term') && $category->taxonomy === 'product_cat') { $category_id = $category->term_id; $show_category = get_field('show_category', 'product_cat_' . $category_id); if ($show_category!=1) { return true; // Ocultar este elemento } } return $status; }, 10, 2); add_filter('reycore/elementor/hide_element/pump_show_boxers_category', function( $status, $element ){ $category = get_queried_object(); if ($category && is_a($category, 'WP_Term') && $category->taxonomy === 'product_cat') { $category_id = $category->term_id; $show_boxers_category = get_field('show_boxers_category', 'product_cat_' . $category_id); if ($show_boxers_category!=1) { return true; // Ocultar este elemento } } return $status; }, 10, 2); add_filter('reycore/elementor/hide_element/pump_show_brief_category', function( $status, $element ){ $category = get_queried_object(); if ($category && is_a($category, 'WP_Term') && $category->taxonomy === 'product_cat') { $category_id = $category->term_id; $show_brief_category = get_field('show_brief_category', 'product_cat_' . $category_id); if ($show_brief_category!=1) { return true; // Ocultar este elemento } } return $status; }, 10, 2); add_filter('reycore/elementor/hide_element/pump_show_backless_category', function( $status, $element ){ $category = get_queried_object(); if ($category && is_a($category, 'WP_Term') && $category->taxonomy === 'product_cat') { $category_id = $category->term_id; $show_backless_category = get_field('show_backless_category', 'product_cat_' . $category_id); if ($show_backless_category!=1) { return true; // Ocultar este elemento } } return $status; }, 10, 2); add_filter('reycore/elementor/hide_element/pump_show_jockstrap_category', function( $status, $element ){ $category = get_queried_object(); if ($category && is_a($category, 'WP_Term') && $category->taxonomy === 'product_cat') { $category_id = $category->term_id; $show_backless_category = get_field('show_jockstrap_category', 'product_cat_' . $category_id); if ($show_backless_category!=1) { return true; // Ocultar este elemento } } return $status; }, 10, 2); add_filter('reycore/elementor/hide_element/pump_show_thong_category', function( $status, $element ){ $category = get_queried_object(); if ($category && is_a($category, 'WP_Term') && $category->taxonomy === 'product_cat') { $category_id = $category->term_id; $show_backless_category = get_field('show_thong_category', 'product_cat_' . $category_id); if ($show_backless_category!=1) { return true; // Ocultar este elemento } } return $status; }, 10, 2); /*Cambiar select size por add to cart para las socks*/ add_action('woocommerce_after_shop_loop_item_title', 'add_to_cart_socks', 10); function add_to_cart_socks() { global $product; // Verificar si el producto tiene la categoría "classics" if ( has_term( 'socks', 'product_cat', $product->get_id() ) ) { add_filter('woocommerce_product_add_to_cart_text', 'change_add_to_cart_text', 10, 2); } } function change_add_to_cart_text($text, $product) { // Cambiar el texto solo si el producto es de la categoría "socks" if ( has_term( 'socks', 'product_cat', $product->get_id() ) ) { $text = __('Add to cart', 'woocommerce'); } return $text; } //Cambiar mensaje cuando no se selecciona una talla function custom_woocommerce_alert_text( $translated_text, $text, $domain ) { if ( function_exists( 'weglot_get_current_language' ) ) { $currentLang = weglot_get_current_language(); if ( $text === 'Please select some product options before adding this product to your cart.' ) { if ( $currentLang == "fr" ) { $translated_text = "Veuillez sélectionner une taille avant d'ajouter ce produit à votre panier."; } else { $translated_text = 'Please select a size before adding this to your cart.'; } } } return $translated_text; } add_filter( 'gettext', 'custom_woocommerce_alert_text', 20, 3 ); // YayCommerce sale tag personalizacion add_action('template_redirect', function () { ob_start('reemplazar_yaydp_sale_tag'); }); function reemplazar_yaydp_sale_tag($html) { return preg_replace_callback( '#