Respuestas de foro creadas

Viendo 15 respuestas - de la 31 a la 45 (de un total de 46)
  • Iniciador del debate ele

    (@luishgc93)

    gracias

    Iniciador del debate ele

    (@luishgc93)

    si, disculpa no cambie el hook, pero seria:

    add_filter(‘woocommerce_email_subject_customer_completed_order’, ‘change_admin_email_subject’, 10, 2);

    Iniciador del debate ele

    (@luishgc93)

    con esto ya funcionó , muchas gracias por la ayuda 😀 :

    function change_admin_email_subject( $subject, $order ) {
        // Get items
        $items = $order->get_items();
    
        foreach ( $items as $item ) {
            // Get product object
            $product = wc_get_product( $item['product_id'] );
    
            // Get product id
            $product_id = $product->get_id();
    
            if ( $product_id == 153 ) {
                $subject = '¡Bienvenida al Curso Online 4';
            } elseif ( $product_id == 192 ) { 
                $subject = '¡Bienvenida al Curso Online d2'; 
            } else {
                $subject = '¡Bienvenida al Curso Online 3'; 
            }
        }
    
        return $subject;
    }
    add_filter('woocommerce_email_subject_new_order', 'change_admin_email_subject', 10, 2);
    Iniciador del debate ele

    (@luishgc93)

    Al cambiar el producto a pedido completado da el error que muestro abajo y no llega el correo ni nada. 🙁
    probe con copiar el codigo tal cual y no funciona

    Ha habido un error crítico en tu web. Por favor, revisa el buzón del correo electrónico de administración de tu sitio para instrucciones.

    Aprende más sobre la depuración en WordPress.

    • Esta respuesta fue modificada hace 4 años, 2 meses por ele.
    • Esta respuesta fue modificada hace 4 años, 2 meses por ele.
    Iniciador del debate ele

    (@luishgc93)

    Buenas,

    tengo la versión PRO y no encuentro que opción habría que marcar para añadir como un segundo sku al producto.

    Iniciador del debate ele

    (@luishgc93)

    gracias LGrusin por tu gran ayuda ! pero no me funciona 🙁 da error

    Iniciador del debate ele

    (@luishgc93)

    no reconoce woocommerce_email_subject_customer_completed_order , da fallo 🙁

    <?php
    /*
    Plugin Name: Woocommerce Cambiar Asunto
    Plugin URI: http://midominio.com
    Description: Plugin de funciones varias
    Author: LuisHgc93
    Version: 1.0
    Author URI: ds.com
    */
    /*
    * Nuevas variables a las plantillas de correo
    */
    
    add_filter( 'woocommerce_email_subject_customer_completed_order' , 'filter_email_format_string', 20, 2 );
    function filter_email_format_string( $string, $email ) {
     // Get the instance of the WC_Order object
     $order = $email->object;
     $items = $order->get_items();
      foreach ( $items as $item ) {
      $product_id = $item['product_id'];
      if ( $product_id == 153 ) {
         $subject = '¡Bienvenida al Curso Online 2';
      } elseif ( $product_id == 192 ) { 
        $subject = '¡Bienvenida al Curso Online 1!'; 
      } else {
      	 $subject = '¡Bienvenida al Curso 0!'; 
      }
     return $subject;
     }
    
     // Additional wanted placeholders in the array of find / relace pairs
     $additional_placeholders = array('{producto}' => $subject, );
    
     return str_replace( array_keys( $additional_placeholders ), array_values( $additional_placeholders ), $string );
    }
    
    Iniciador del debate ele

    (@luishgc93)

    y cual es el metodo que te consigue el correo del pedido completado?

    Iniciador del debate ele

    (@luishgc93)

    solucionado mediante otra vía

    Iniciador del debate ele

    (@luishgc93)

    De momento tengo esto :

    <?php
    /**
     * Customer completed order email
     *
     * This template can be overridden by copying it to yourtheme/woocommerce/emails/customer-completed-order.php.
     *
     * HOWEVER, on occasion WooCommerce will need to update template files and you
     * (the theme developer) will need to copy the new files to your theme to
     * maintain compatibility. We try to do this as little as possible, but it does
     * happen. When this occurs the version of the template file will be bumped and
     * the readme will list any important changes.
     *
     * @see https://docs.woocommerce.com/document/template-structure/
     * @package WooCommerce/Templates/Emails
     * @version 3.7.0
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
        exit;
    }
    
    /*
     * @hooked WC_Emails::email_header() Output the email header
     */
    do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
    
    <?php /* translators: %s: Customer first name */ ?>
    <p><?php printf( esc_html__( 'Hi %s,', 'woocommerce' ), esc_html( $order->get_billing_first_name() ) ); ?></p>
    
    <?php
    /*
     * @hooked WC_Emails::order_details() Shows the order details table.
     * @hooked WC_Structured_Data::generate_order_data() Generates structured data.
     * @hooked WC_Structured_Data::output_structured_data() Outputs structured data.
     * @since 2.5.0
     */
    
    do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $email );
    
    

    pero me saca los datos sin tabla, y necesito quitar esos datos.

    Iniciador del debate ele

    (@luishgc93)

    genial, hice una combinación de los dos y funcionó como yo quería:

    add_filter( 'woocommerce_email_format_string' , 'filter_email_format_string', 20, 2 );
    function filter_email_format_string( $string, $email ) {
     // Get the instance of the WC_Order object
     $order = $email->object;
     $items = $order->get_items();
      foreach ( $items as $item ) {
      $product_id = $item['product_id'];
      if ( $product_id == 15733 ) {
         $subject = '¡Bienvenida al Curso Online A!';
      } elseif ( $product_id == 132 ) { 
        $subject = '¡Bienvenida al Curso Online de casas'; 
      } else {
      	 $subject = '¡Bienvenida al Curso Online de venta de coches!'; 
      }
     return $subject;
     }
    
     // Additional wanted placeholders in the array of find / relace pairs
     $additional_placeholders = array('{producto}' => $subject, );
    
     return str_replace( array_keys( $additional_placeholders ), array_values( $additional_placeholders ), $string );
    }
    Iniciador del debate ele

    (@luishgc93)

    gracias!

    Iniciador del debate ele

    (@luishgc93)

    Una pregunta, como harías con un if para comparar que si es un producto pues salga un asunto en el correo. Y si es otro producto, pues que salga otro asunto.

    Iniciador del debate ele

    (@luishgc93)

    genial gracias ! funcionó

    ele

    (@luishgc93)

    y para añadir el nombre del producto ? en vez del nombre del comprador? no encuentro el hook para el nombre del producto.

    • Esta respuesta fue modificada hace 4 años, 2 meses por ele.
Viendo 15 respuestas - de la 31 a la 45 (de un total de 46)