• Resolved miguel

    (@miguelappstudio)


    Hello, congratulations on the product, I like it.
    I’m still testing, but I have some doubts.
    I want to add some products to the file, I already have other own brands created. In one I can add an image I want to each product and in the other I can add custom text to each product.

    The problem arises when I want to add the Countdown Timer Ultimate shortcode, since it is not displayed, the generated shortcode code itself is displayed: [wpcdt-countdown id=”6369″] , instead of showing me the numbers.

    I have also tried to do it with another of your options:

    this doesn’t work for me either.

    Can you help me to insert the shortcode in my file?

    What am I doing wrong ?

    * Registramos el Metabox
    ============================================================================= */
    
    function biogredos_custom_product_metabox(){
    
      // Memberships Metabox
      add_meta_box( 
          'product-custom-settings', 
          __( 'Producto', 'textdomain' ), 
          'custom_product_callback', 
          'product' 
      );
    
    }
    add_action( 'add_meta_boxes', 'biogredos_custom_product_metabox' );
    
    
    /* Agregamos los campos
    ============================================================================= */
    
    
    function custom_product_callback(){
    
      $screen = get_current_screen();
      if ( $screen->action !== 'add' ) :
    
          global $post;
          $post_id = $post->ID;
    
          $logo = get_post_meta( $post_id, 'ct_product_logo', true );
          $texto = get_post_meta( $post_id, 'ct_product_title', true );
          // Countdown Timer Ultimate shortcode
          $descuento = get_post_meta( $post_id, 'ct_product_contando', true );
    
      else :
    
          $logo = '';
          $texto =  '';
    	  $descuento = '';
    
      endif;
    
      // Logo
      echo '<div class="trn-form-control">';
      echo '<div class="trn-row">';
      echo '<div class="trn-col-2"><label>Logo</label></div>';
      echo '<div class="trn-col-10">';
      echo '<input type="text" id="custom-product-logo" name="custom-product-logo" value="' . $logo . '">';
      echo '</div>';
      echo '</div>';
      echo '</div>';
    
      // Titulo
      echo '<div class="trn-form-control">';
      echo '<div class="trn-row">';
      echo '<div class="trn-col-2"><label>Titulo</label></div>';
      echo '<div class="trn-col-10">';
      echo '<input type="text" id="custom-product-title" name="custom-product-title" value="' . $texto . '">';
      echo '</div>';
      echo '</div>';
      echo '</div>';
    	
    	
     // Descuento 
    // Countdown Timer Ultimate shortcode
      echo '<div class="trn-form-control">';
      echo '<div class="trn-row">';
      echo '<div class="trn-col-2"><label>Shortcode</label></div>';
      echo '<div class="trn-col-10">';
      echo '<input type="text" id="custom-product-contando" name="custom-product-contando" value="' . $descuento . '">';
      echo '</div>';
      echo '</div>';
      echo '</div>';	
    
    }
    
    /* Guardamos los datos
    ============================================================================= */
    
    function biogredos_product_save_custom( $post_id ) {
    
      $post_type = get_post_type( $post_id );
      if ( $post_type == 'product' ) :
    
          $logo  = sanitize_text_field( $_POST['custom-product-logo'] );
          $titulo  = sanitize_text_field( $_POST['custom-product-title'] );
           // Countdown Timer Ultimate shortcode
          $contando = sanitize_text_field( $_POST['custom-product-contando'] );
    	
          update_post_meta( $post_id, 'ct_product_logo', $logo );
          update_post_meta( $post_id, 'ct_product_title', $titulo );
          // Countdown Timer Ultimate shortcode
          update_post_meta( $post_id, 'ct_product_contando', $contando );
    
      endif;
    
    }
    add_action( 'save_post', 'biogredos_product_save_custom');
    
    
    /* Mostramos los datos
    ============================================================================= */
    
    
    function biogredos_show_custom_product_data(){
    
      global $product;
      $post_id = $product->get_id();
    
      $logo = get_post_meta( $post_id, 'ct_product_logo', true );
      $texto = get_post_meta( $post_id, 'ct_product_title', true );
       // Countdown Timer Ultimate shortcode
      $shortcode = get_post_meta( $post_id, 'ct_product_contando', true );
    	
      if ( $logo ) :
          echo '<img class="degradableimage" src="' . $logo . '">';
      endif;
    
      if ( $texto ) :
          echo '<p class="degradable">'. $texto . '</p>';
      endif;
     
     // Countdown Timer Ultimate shortcode
     if ( $shortcode ) :
          echo '<p class="descuento">'. $shortcode . '</p>';
      endif;	
    	
    }
    add_action( 'woocommerce_after_shop_loop_item_title', 'biogredos_show_custom_product_data' );
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘how to add the shortcode in my file?’ is closed to new replies.