• 0
Votes
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /var/www/html/cnasolution/site/application/views/question.php
Line: 191
Function: _error_handler

File: /var/www/html/cnasolution/site/application/controllers/Questions.php
Line: 419
Function: view

File: /var/www/html/cnasolution/site/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

WooCommerce Change Product Variation Dropdown Text

I need some assistance with customizing woocommerce variation dropdown text display. I am using a plugin called IgniteWoo WooEvents Pro to create events via woocommerce. The events have start dates and end dates, which I would like to display on the dropdown. But the way the plugin works, it only displays the start date and time.

Please see below:

Currently it displays the following in the dropdown box: (only the start date & a time, which is unnecessary)

22 Jan 2020 09:00 am

What we need it to display is as follows:

22 Jan 2020 - 24 Jan 2020

Unfortunately the dates are displayed as this in product attributes and I cannot change them, because then the plugin does not work.

I have chatted to the plugin developer, but all he can tell me is I need to change something in

plugins/woocommerce/templates/single-product/add-to-cart/variation.php 

I assume I need to change the attribute name when displayed in the dropdown via woocommerce, but I don't know how to pull in the start date & end date of the events.

I have no idea what I'm doing - please can you help.

In the plugin I found this section regarding variables:

     function woocommerce_available_variation( $variations, $_product, $variation ) {          global $ignitewoo_events;           if ( empty( $variations['attributes']['attribute_date'] ) || empty( $_product->post->ID ) )             return $variations;          if ( 'yes' != get_post_meta( $_product->post->ID, '_ignitewoo_event', true ) )             return $variations;          $attr = strtoupper( str_replace( '-', ' ', $variations['attributes']['attribute_date'] ) );          $attr = substr( $attr, 0, 6 ) . ', ' . substr( $attr, 7, 4 );          $date = strtotime( $attr );          if ( empty( $date ) )             return $variations;          if ( current_time( 'timestamp', false ) > $date ) {             //return array(); // no longer works when returning empty array, so unset vars instead.             $variations['attributes']['is_purchasable'] = false;             $variations['attributes']['is_in_stock'] = false;             $variations['attributes']['backorders_allowed'] = false;             $variations['attributes']['display_price'] = false;             $variations['attributes']['display_regular_price'] = false;             $variations['is_purchasable'] = false;             $variations['is_in_stock'] = false;             $variations['backorders_allowed'] = false;             $variations['variation_is_visible'] = false;             $variations['variation_is_active'] = false;         }          /*         $event_info = $ignitewoo_events->get_post_data();          if ( !empty( $event_info['stop_purchase_interval'] ) ) {             $interval = absint( $event_info['stop_purchase_interval'] );             $type = $event_info['stop_purchase_interval_type'];             $target = $event_info['stop_purchase_start_end'];             if ( $interval > 0 ) {               }         }         */         return $variations;     } 

And here is also a section where it shows that variables for $start_date and $end_date exist. So surely I can pull them into the dropdown?

        global $post;          if ( !isset( $post_id ) )              $post_id = $post->ID;           if ( !$post_id )              return;          if ( !isset( $start_date ) || !isset( $end_date ) )              return;          $start_date = strtotime( $start_date );          $end_date = strtotime( $end_date );          $dates = date( 'Ymd', $start_date  ) . 'T' . date( 'Hi00', $start_date ) . '/' . date( 'Ymd', $end_date ) . 'T' . date( 'Hi00', $end_date );          $settings = get_post_meta( $post_id, '_ignitewoo_event_info', true ); 

I honestly don't know what I'm doing. Any tips would help. If needs be, I can paste all the code of the plugin here, but I doubt the dev would appreciate that very much. I just really need some assistance.

And this is the woocommerce add-to-cart variation page, where I'm supposed to make the change???

  

$options ) : ?>
$options, 'attribute' => $attribute_name, 'product' => $product, ) ); echo end( $attribute_keys ) === $attribute_name ? wp_kses_post( apply_filters( 'woocommerce_reset_variations_link', '' . esc_html__( 'Clear', 'woocommerce' ) . '' ) ) : ''; ?>
Download script demo [LINK]
Download script demo [LINK 2] Download script demo [LINK 2]