[Support request] shortcode for woocommerce date?

Home Forums Support [Support request] shortcode for woocommerce date?

Home Forums Support shortcode for woocommerce date?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2025251
    nomadiceman

    hi guys,

    I’m starting my first eCommerce site so I apologise if my questions are a little stupid

    I’ve got the FooEvents plugin installed and really would like to pull the event date into the block elements header

    do you know what the shortcode is for this? I’m not sure what I am trying to find. is it even possible?

    thank you for your help

    #2025253
    nomadiceman

    I’ve found this snippet on the FooEvents website

    
    function fooevents_display_date_on_single() {
      global $post;
      $product = wc_get_product( $post->ID );
      $start_date = $product->get_meta( 'WooCommerceEventsDate' );
      $end_date = $product->get_meta( 'WooCommerceEventsEndDate' );
      if ( $end_date ) {
        printf(
          '<h3>%s</h3>',
          esc_html( $start_date . ' - ' . $end_date )
        );
      } else if( $start_date ) {
        printf(
          '<h3>%s</h3>',
          esc_html( $start_date )
        );
      }
    }
    add_action( 'woocommerce_single_product_summary', 'fooevents_display_date_on_single' );
    

    does that help?

    #2025256
    nomadiceman

    or this

    
    function fooevents_display_time_in_shop_listing() {
    global $post;
    if (is_front_page() || is_home() || is_shop() || is_product_category() || is_product_tag()) {
    echo '<div class="fooevents-date">';
    echo get_post_meta($post->ID, 'WooCommerceEventsHour', true).':';
    echo get_post_meta($post->ID, 'WooCommerceEventsMinutes', true). ' ';
    echo get_post_meta($post->ID, 'WooCommerceEventsPeriod', true);
    echo '</div>';
    }
    }
    add_filter( 'woocommerce_after_shop_loop_item_title', 'fooevents_display_time_in_shop_listing', 35 );
    
    #2025261
    Leo
    Staff
    Customer Support

    Hi there,

    I’m not familiar with FooEvents plugin unfortunately.

    I would recommend checking with their support team first to see if there is a shortcode you can use.

    You can always test the code you’ve found above by using the Code Snippets plugin:
    Adding PHP: https://docs.generatepress.com/article/adding-php/

    The first one is adding some content to the woocommerce_single_product_summary hook and the second one is a filter for woocommerce_after_shop_loop_item_title.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.