Fuctions - PHP Kalex
Fuctions - PHP Kalex
php
// Exit if accessed directly
if (!defined('ABSPATH')) exit;
if (!function_exists('chld_thm_cfg_locale_css')) :
function chld_thm_cfg_locale_css($uri) {
if (empty($uri) && is_rtl() && file_exists(get_template_directory() .
'/rtl.css'))
$uri = get_template_directory_uri() . '/rtl.css';
return $uri;
}
endif;
add_filter('locale_stylesheet_uri', 'chld_thm_cfg_locale_css');
if (!function_exists('child_theme_configurator_css')) :
function child_theme_configurator_css() {
wp_enqueue_style('chld_thm_cfg_child',
trailingslashit(get_stylesheet_directory_uri()) . 'style.css', array('astra-theme-
css', 'woocommerce-layout', 'woocommerce-smallscreen', 'woocommerce-general'));
}
endif;
add_action('wp_enqueue_scripts', 'child_theme_configurator_css', 10);
try {
// Obtener el pedido
$order = wc_get_order($order_id);
if (!$order) {
throw new Exception('No se pudo obtener el pedido.');
}
function redirigir_despues_de_compra() {
// Verificar si estamos en la página de "Gracias" (Thank You)
if (is_wc_endpoint_url('order-received')) {
// Redirigir a la página de inicio después de 5 segundos
wp_redirect('https://ganaconkalex.com/gracias'); // Cambia la URL si es
necesario
exit;
}
}
function buscador_metadatos_woocommerce($atts) {
// Atributos del shortcode (opcional)
$atts = shortcode_atts(array(
'placeholder' => 'Buscar...', // Texto del placeholder del input
'button_text' => 'Buscar', // Texto del botón de búsqueda
), $atts, 'buscador_metadatos');
function crear_boton_copiar_datos() {
// Datos que se copiarán
$datos = 'Mercantil (0105) 24741018 04125537766';
return $html;
}
function script_boton_copiar_datos() {
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('.boton-copiar').on('click', function() {
var datos = $(this).data('datos'); // Obtiene los datos del
atributo data-datos
function crear_botones_aumentar_cantidad() {
// Valores de los botones
$valores = array(5, 10, 25, 50, 100);
return $html;
}
function script_botones_aumentar_cantidad() {
if ( is_checkout() ) { // Solo en la página de checkout
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('.boton-aumentar-cantidad').on('click', function() {
var nuevaCantidad = $(this).data('valor'); // Obtiene el valor
del botón
function manejar_actualizacion_cantidad_carrito() {
// Verifica el nonce para seguridad
if (!wp_verify_nonce($_POST['security'], 'actualizar-cantidad-carrito')) {
wp_send_json_error('Error de seguridad.');
}
if (!$producto_encontrado) {
wp_send_json_error('Producto no encontrado en el carrito.');
}
if (
'edit.php' === $pagenow
&& isset( $_GET['_billing_tickets'] )
&& ! empty( $_GET['_billing_tickets'] )
&& 'shop_order' === $query->query['post_type']
) {
$ticket_number = sanitize_text_field( $_GET['_billing_tickets'] );
$meta_query = array(
array(
'key' => '_billing_tickets', // Clave actualizada
'value' => $ticket_number,
'compare' => '='
)
);
$query->set( 'meta_query', $meta_query );
}
return $query;
}