<?php
/*
Plugin Name: Mi Plugin de funciones
Description: Mis funciones personales para el sitio web
Version: 1.0
Author: Eduardo Varela
*/
//AMBASSADOR CUSTOM CHECKOUT FIELDS, CONTENT
add_action( 'woocommerce_after_checkout_billing_form', 'aym_custom_checkout_field' );
function aym_custom_checkout_field( $checkout ) {
//Check if Product in Cart
$product_carrito = aym_is_conditional_product_in_cart_2863(2773);
if ( $product_carrito === true ) {
add_filter('gettext', 'translate_text');
add_filter('ngettext', 'translate_text');
function translate_text($translated) {
$translated = str_ireplace('¿Enviar a una dirección diferente?', 'Quieres regalar el articulo a otra persona?', $translated);
return $translated;
}
}
}
//TEAM LEADER BUNDLE
function aym_is_conditional_product_in_cart_2863( $product_id ) {
//Check to see if user has product in cart
global $woocommerce;
//flag no product in cart
$product_carrito = false;
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) {
$_product = $values['data'];
if ( $_product->id === $product_id ) {
//product is in cart!
$product_carrito = true;
}
}
return $product_carrito ;
}