Argomenti

⌘K
  1. Argomenti
  2. Snippet di codice

Snippet di codice

Questo è un A livello di sviluppatore documento. Se non si ha dimestichezza con il codice/template e la risoluzione di potenziali conflitti, si consiglia di rivolgersi a uno sviluppatore che abbia familiarità con l'FooEvents e/o l'WooCommerce.

Importante, leggere prima #

Questi snippet sono forniti a titolo di cortesia e non fanno parte dell'offerta di prodotti FooEvents. Sono considerati personalizzazioni e non sono ufficialmente supportati da FooEvents. Di conseguenza, non forniamo supporto per gli snippet e le personalizzazioni, come previsto dalla nostra Termini di servizio. Utilizzare a proprio rischio e pericolo.

Completare automaticamente gli ordini #

Questo permette di inviare automaticamente i biglietti una volta ricevuto il pagamento, invece di dover completare manualmente l'ordine. Assicuratevi che i prodotti dell'evento siano impostati su "Virtuale" e "Scaricabile", come spiegato nel nostro documentazione di aiutoaltrimenti, l'ordine non completare automaticamente anche se il pagamento è stato effettuato.

Aggiungere il seguente codice al tema figlio functions.php o tramite un plugin che permetta di aggiungere funzioni personalizzate, come il file Snippet di codice plugin. Evitare di aggiungere codice personalizzato direttamente al tema padre functions.php perché verrà sovrascritto quando si aggiorna il tema.

Si può anche cambiare lo stato "Completato" con un altro stato dell'ordine, ad esempio "In elaborazione".

/**
 * @snippet       Programmatically Complete Paid WooCommerce Orders
 * @how-to        businessbloomer.com/woocommerce-customization
 * @author        Rodolfo Melogli, Business Bloomer
 * @testedwith    WooCommerce 9
 * @community     https://businessbloomer.com/club/
 */
 
add_filter( 'woocommerce_payment_complete_order_status', 'bbloomer_autocomplete_processing_orders', 9999 );
 
function bbloomer_autocomplete_processing_orders() {
   return 'completed';
}

Note that the above code snippet won’t work with COD / BACS / Cheque orders when order total is > 0. Check the free plugin on this page to get this sorted.

Mostra il nome e l'email del partecipante nell'email di amministrazione del Nuovo Ordine #

Aggiungete il seguente frammento di codice alla cartella del vostro tema functions.php file. È possibile cambiare l'email in cui viene visualizzato il file utilizzando un'email diversa. gancio.

.

[php]
add_action( 'woocommerce_email_customer_details', 'fooevents_display_attendee_details_in_new_order_email', 10 , 4);
function fooevents_display_attendee_details_in_new_order_email($order, $sent_to_admin, $plain_text, $email){
    echo "<h3>Dettagli sui partecipanti</h3>";
    $WooCommerceEventsOrderTickets = get_post_meta($order-&gt;get_id(), 'WooCommerceEventsOrderTickets', true);
    foreach($WooCommerceEventsOrderTickets as $event) {
        foreach($event as $ticket) {
            echo "<p>";
            echo '<strong>Nome</strong>: '.$ticket['WooCommerceEventsAttendeeName'].'<br />';
            echo '<strong>Cognome</strong>: '.$ticket['WooCommerceEventsAttendeeLastName'].'<br />';
            echo '<strong>Indirizzo e-mail</strong>: '.$ticket['WooCommerceEventsAttendeeEmail'].'<br />';
            echo "</p>";
        }
    }
}

Mostra tutti i campi personalizzati dei partecipanti senza etichette nell'e-mail di amministrazione del nuovo ordine #

Aggiungete il seguente frammento di codice alla cartella del vostro tema functions.php file. È possibile cambiare l'email in cui viene visualizzato il file utilizzando un'email diversa. gancio.

.

[php]
add_action( 'woocommerce_email_customer_details', 'fooevents_display_attendee_details_in_new_order_email', 10 , 4);
function fooevents_display_attendee_details_in_new_order_email($order, $sent_to_admin, $plain_text, $email){
    echo "<h3>Dettagli sui partecipanti</h3>";
    $WooCommerceEventsOrderTickets = get_post_meta($order-&gt;get_id(), 'WooCommerceEventsOrderTickets', true);
    foreach($WooCommerceEventsOrderTickets as $event) {
        foreach($event as $ticket) {
            echo "<p>";
            echo '<strong>Nome</strong>: '.$ticket['WooCommerceEventsAttendeeName'].'<br />';
            echo '<strong>Cognome</strong>: '.$ticket['WooCommerceEventsAttendeeLastName'].'<br />';
            echo '<strong>Indirizzo e-mail</strong>: '.$ticket['WooCommerceEventsAttendeeEmail'].'<br />';
            foreach ($ticket['WooCommerceEventsCustomAttendeeFields'] as $caf) {
                 echo $caf.'<br />';
            }
            echo "</p>";
        }
    }
}

Mostra i campi personalizzati dei partecipanti con le etichette nell'e-mail di amministrazione del Nuovo Ordine #

Aggiungete il seguente frammento di codice alla cartella del vostro tema functions.php file. È possibile cambiare l'email in cui viene visualizzato il file utilizzando un'email diversa. gancio. Assicurarsi di sostituire "ovsxtmynwagotamjqieq" e "ruzwhgbuhzuzzdwnnaxe" nel codice di esempio con il codice del campo personalizzato del partecipante. Potete trovare queste informazioni se modificate un biglietto e cercate ogni campo personalizzato del partecipante nella sezione "Campi personalizzati". È necessario aggiungere ogni campo personalizzato del partecipante e la sua etichetta individualmente.

.

[php]
add_action( 'woocommerce_email_customer_details', 'fooevents_display_attendee_details_in_new_order_email', 10 , 4);
function fooevents_display_attendee_details_in_new_order_email($order, $sent_to_admin, $plain_text, $email){
    echo "<h3>Dettagli sui partecipanti</h3>";
    $WooCommerceEventsOrderTickets = get_post_meta($order-&gt;get_id(), 'WooCommerceEventsOrderTickets', true);
    foreach($WooCommerceEventsOrderTickets as $event) {
        foreach($event as $ticket) {
            echo "<p>";
            echo '<strong>Nome</strong>: '.$ticket['WooCommerceEventsAttendeeName'].'<br />';
            echo '<strong>Cognome</strong>: '.$ticket['WooCommerceEventsAttendeeLastName'].'<br />';
            echo '<strong>Indirizzo e-mail</strong>: '.$ticket['WooCommerceEventsAttendeeEmail'].'<br />';
            echo '<strong>Compleanno</strong>: '.$ticket['WooCommerceEventsCustomAttendeeFields']['fooevents_custom_ovsxtmynwagotamjqieq'].'<br />';
            echo '<strong>Canzone preferita</strong>: '.$ticket['WooCommerceEventsCustomAttendeeFields']['fooevents_custom_ruzwhgbuhzuzzdwnnaxe'].'<br />';
            echo "</p>";
        }
    }
}

Visualizzare l'ora di inizio dell'evento nell'elenco degli eventi #

Aggiungete il seguente frammento di codice alla cartella del vostro tema functions.php file. Per creare uno stile di visualizzazione dell'ora, aggiungere il CSS per la classe 'fooevents-date'.

Cambiate la posizione dell'ora utilizzando un'altra gancio.

.

[php]
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-&gt;ID, 'WooCommerceEventsHour', true).":";
echo get_post_meta($post-&gt;ID, 'WooCommerceEventsMinutes', true). ' ';
echo get_post_meta($post-&gt;ID, 'WooCommerceEventsPeriod', true);
echo '</div>';
}
}
add_filter( 'woocommerce_after_shop_loop_item_title', 'fooevents_display_time_in_shop_listing', 35 );[/php]

Visualizzare i partecipanti registrati in una tabella #

Aggiungete il seguente frammento di codice alla cartella del vostro tema functions.php per visualizzare tutti i partecipanti registrati all'evento in una tabella a griglia. Dopo aver aggiunto lo snippet di codice, è possibile utilizzare lo shortcode in questo modo:

[fooevents_attendees]

per visualizzare tutti i partecipanti a tutti gli eventi, oppure in questo modo:

[fooevents_attendees product_id=123]

dove "123" è l'ID dell'evento per il quale si desidera visualizzare l'elenco dei partecipanti.

function fooevents_display_attendees($attributes) {
 
  $product_id='';
  if(!empty($attributes['product_id'])) {
    $product_id = $attributes['product_id'];
  }

  $output ='';
  $args = array(
    'numberposts' =&gt; -1,
    'posts_per_page' =&gt; -1,
    'post_type' =&gt; 'event_magic_tickets',
    meta_query' =&gt; array(
      'relation' =&gt; 'OR',
      array(
        'key' =&gt; 'WooCommerceEventsProductID',
        'value' =&gt; $product_id,
        'compare' =&gt; 'LIKE'
      )
    )
  );

   $the_query = new WP_Query( $args );

  if( $the_query-&gt;have_posts() ):
    while ( $the_query-&gt;have_posts() ) : $he_query-&gt;the_post();
    $postid = $the_query-&gt;post-&gt;ID;
     
      // produrre tutti i risultati - PERSONALIZZARE A PROPRIO PIACERE
      $output .= "<tr>";
      $output .= "<td>".get_the_title()".</td>";
      $output .= "<td>".get_post_meta($postid, 'WooCommerceEventsPurchaserFirstName', true)".</td>";
      $output .= "<td>".get_post_meta($postid, 'WooCommerceEventsPurchaserLastName', true)".</td>";
      $output .= "</tr>";
         
    endwhile;
  endif;
  wp_reset_query();
  $output ="<table>".$output".</table>";
  restituire $output;
   
}
add_shortcode("fooevents_attendees", "fooevents_display_attendees");
[/php]

Visualizzare la data dell'evento prima del titolo nella pagina del prodotto #

Cambiate la posizione della data utilizzando un'altra gancio.

.

[php]
function fooevents_display_date_on_single() {
  global $post;
  $product = wc_get_product( $post-&gt;ID );
  $start_date = $product-&gt;get_meta( 'WooCommerceEventsDate' );
  $end_date = $product-&gt;get_meta( 'WooCommerceEventsEndDate' );
  se ( $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' );

Se si desidera rendere disponibile la data dell'evento come shortcode, è possibile aggiungere la seguente riga sotto la funzione:

add_shortcode( 'fooevents_date_on_single', 'fooevents_display_date_on_single');

Quindi è possibile utilizzare lo shortcode [fooevents_date_on_single] per visualizzare la data dell'evento nella pagina.

Sostituire l'icona del posto a sedere sulla tabella dei posti con un'immagine diversa. #

Modificare il seguente frammento di codice CSS aggiungendo l'URL di un'immagine diversa che si desidera sostituire a quella predefinita per tutti i posti a sedere. Aggiungere il frammento di codice modificato al file CSS personalizzato del tema.

#fooevents_seating_dialog .fooevents_seating_chart_view_row span {
  background-image: url(../images/seat.svg);
}

Rimuovete l'icona del posto a sedere sulla tabella dei posti a sedere in modo che i posti vengano visualizzati come scatole #

#fooevents_seating_dialog .fooevents_seating_chart_view_row span {
  background-image: none;
}

Modificare la direzione dei numeri dei posti a sedere sulla tabella dei posti a sedere #

#fooevents_seating_dialog .fooevents_seating_chart_view_row {
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
}

Mostra i posti dispari a destra e quelli pari a sinistra. #

#fooevents_seating_dialog .fooevents_seating_chart_view_row > span:nth-of-type(even) {
  float: left;
}

Visualizzare i posti al centro della tabella dei posti a sedere #

[css]
#fooevents_seating_dialog .fooevents_seating_chart_view_row_name,
#fooevents_seating_dialog .fooevents_seating_chart_view_row {
  text-align: center;
}
[/css]

Lasciare che la tabella dei posti a sedere scorra orizzontalmente invece di visualizzare i posti nella fila successiva #

Questo può essere utile se si hanno molti posti per fila e si vuole che vengano visualizzati uno accanto all'altro invece che sulla fila successiva, se non si adattano a una riga.

#fooevents_seating_dialog .fooevents_seating_chart_view_row {
  overflow-x: scroll;
  white-space: nowrap;
}

Mostrare una griglia di calendario su desktop e un elenco di settimane di calendario su mobile #

Aggiungete due shortcode di calendario nella pagina o nel post in cui volete visualizzare il calendario. Il primo shortcode visualizzerà una griglia di calendari e dovrebbe avere questo aspetto:

[fooevents_calendar id="desktop"]

Il secondo shortcode visualizzerà un elenco di settimane del calendario e dovrebbe avere questo aspetto:

[fooevents_calendar id="mobile" defaultView="listWeek"]

Aggiungere il seguente frammento di codice CSS al file CSS personalizzato del tema. Assicurarsi che il valore del selettore CSS ID sia uguale al valore dell'attributo "id" specificato nel codice breve. È possibile regolare la proprietà "max-width" in base alla dimensione dello schermo in cui si desidera che l'elenco delle settimane del calendario sia visualizzato e la griglia del calendario sia nascosta.

#desktop_fooevents_calendar {
  display: block;
}
    
#mobile_fooevents_calendar {
  display: none;
}
    
@media screen and (max-width: 600px) {
  #desktop_fooevents_calendar {
    display: none;
  }
    
  #mobile_fooevents_calendar {
    display: block;
  }    
}

Modificare la posizione dell'icona Copia dei dettagli dell'acquirente #

Lo snippet seguente allinea il pulsante di copia a destra dell'etichetta del nome:

.fooevents-copy-from-purchaser {
	float: destra;
	margin-bottom:-1.7em
}

Se non si utilizzano etichette, ma segnaposti di input, utilizzare il seguente frammento di codice:

.fooevents-copy-from-purchaser {
	float: destra;
	margin-top:-2em
}

Mostrare la scheda "Dettagli evento" per prima nella pagina dell'evento #

Aggiungete il seguente frammento di codice alla cartella del vostro tema functions.php file.

add_filter( 'woocommerce_product_tabs', 'reorder_tabs', 98 );
function reorder_tabs( $tabs ) {

    $tabs['woocommerce_events']['priority'] = 1;
    return $tabs;

}

Indirizzare tutti i pulsanti "Aggiungi al carrello" alle pagine dei prodotti #

Se un prodotto è un prodotto semplice, per impostazione predefinita, il pulsante "Aggiungi al carrello" aggiungerà automaticamente un prodotto al carrello del cliente. Se si utilizza l'estensione FooEvents Bookings, è possibile che i clienti debbano prima accedere alla pagina del prodotto per selezionare la data e la fascia oraria della prenotazione. Lo snippet seguente assicura che quando si fa clic sul pulsante 'Aggiungi al carrello' per i prodotti semplici, l'utente venga indirizzato alla pagina del prodotto.

add_filter( 'woocommerce_loop_add_to_cart_link', 'fooevents_modify_add_to_cart_button_url', 10, 2 );
function fooevents_modify_add_to_cart_button_url( $button, $product ) {
    se (is_product_category() || is_shop()) {
        $button_text = $product-&gt;add_to_cart_text();
        $button_link = $product-&gt;get_permalink();
        $button = '<a class="button" href="/it/' . $button_link . '/">' . $button_text . '</a>';
        restituire $button;
    }
}

Visualizza FREE se il prezzo dell'evento è impostato su zero (0) #

Aggiungete il seguente frammento di codice alla cartella del vostro tema functions.php se si desidera cambiare gli eventi e i prodotti con un prezzo di "0" in "GRATIS". È anche possibile sostituire la parola "GRATIS" con un'altra parola o frase o lasciarla vuota se non si desidera visualizzare nulla.

add_filter( 'woocommerce_get_price_html', 'wp_price_free_zero_empty', 100, 2 );
function wp_price_free_zero_empty( $price, $product ) {
	 if ( '' === $product->get_price() || 0 == $product->get_price() ) {
		$price = 'FREE';
	}
	return $price;
}

Visualizzare i prodotti e le varianti (biglietti) in una tabella a griglia #

Aggiungete il seguente frammento di codice alla cartella del vostro tema functions.php per visualizzare i prodotti e le varianti in una tabella a griglia nella pagina dell'evento/prodotto, invece dell'elenco a discesa predefinito. Ogni opzione di biglietto sarà elencata in una nuova riga e avrà il proprio selettore di quantità.

Si prega di notare: Questo frammento di codice è incompatibile con l'applicazione FooEvents Posti a sedere e il Visualizzazione delle opzioni di seduta nelle pagine dei prodotti opzione. Dovrebbe funzionare con gli eventi con posti a sedere se si visualizza la tabella dei posti a sedere solo nella pagina della cassa.

/** Add your event IDs in array like this
 * if you only want certain events
 * to display variations in a table: 
 * array( 123, 456 ) 
 */
$products              = array(  );
$products_multi_button = array(  );

/**
 * Add multiple variations with quantities at once in add to cart url using notation "<product_id or variation_id>:<product_quantity>,..."
 */
function fooevents_add_multiple_products_to_cart( $url = false ) {

    if ( ! empty( $_GET['add-to-cart'] ) ) {

        // Make sure WC is installed and add-to-cart query arg exists
        if ( ! class_exists( 'WC_Form_Handler' ) || empty( $_REQUEST['add-to-cart'] ) ) {
            return;
        }

        // Remove WooCommerce's hook since it doesn't handle multiple products/variations
        remove_action( 'wp_loaded', array( 'WC_Form_Handler', 'add_to_cart_action' ), 20 );

        $product_ids = explode( ',', $_REQUEST['add-to-cart'] );
        $count       = count( $product_ids );
        $number      = 0;

        foreach ( $product_ids as $id_and_quantity ) {

            if ( ! empty( $_GET['fooevents_bookings_method'] ) ) {
                $_POST['fooevents_bookings_method'] = $_GET['fooevents_bookings_method'];
            } else {
                $_POST['fooevents_bookings_method'] = 'slotdate';
            }

            if ( ! empty( $_GET['bookings_sid'] ) ) {
                $_POST['fooevents_bookings_slot_val__trans'] = $_GET['bookings_sid'];
            }

            if ( ! empty( $_GET['bookings_did'] ) ) {
                $_POST['fooevents_bookings_date_val__trans'] = $_GET['bookings_did'];
            }

            if ( ! empty( $_GET['bookings_slot_date'] ) ) {
                $_POST['fooevents_bookings_slot_date_val_trans'] = $_GET['bookings_slot_date'];
            }

            // Check for quantities defined in notation (<product_id or variation_id>:<product_quantity>)

            $id_and_quantity = explode( ':', $id_and_quantity );
            $product_id      = $id_and_quantity[0];

            $_REQUEST['quantity'] = ! empty( $id_and_quantity[1] ) ? absint( $id_and_quantity[1] ) : 1;

            if ( ++$number === $count ) {
                // Send back to WooCommerce's add_to_cart_action method for handling.
                $_REQUEST['add-to-cart'] = $product_id;
                return WC_Form_Handler::add_to_cart_action( $url );
            }

            $product_id        = apply_filters( 'woocommerce_add_to_cart_product_id', absint( $product_id ) );
            $was_added_to_cart = false;
            $adding_to_cart    = wc_get_product( $product_id );

            if ( ! $adding_to_cart ) {
                continue;
            }

            $add_to_cart_handler = apply_filters( 'woocommerce_add_to_cart_handler', $adding_to_cart->get_type(), $adding_to_cart );

            // Variable product handling
            if ( 'variable' === $add_to_cart_handler ) {
                fooevents_invoke_multiple_adds( 'WC_Form_Handler', 'add_to_cart_handler_variable', $product_id );

                // Grouped Products
            } elseif ( 'grouped' === $add_to_cart_handler ) {
                fooevents_invoke_multiple_adds( 'WC_Form_Handler', 'add_to_cart_handler_grouped', $product_id );

                // Custom Handler
            } elseif ( has_action( 'woocommerce_add_to_cart_handler_' . $add_to_cart_handler ) ) {
                do_action( 'woocommerce_add_to_cart_handler_' . $add_to_cart_handler, $url );

                // Simple Products
            } else {
                fooevents_invoke_multiple_adds( 'WC_Form_Handler', 'add_to_cart_handler_simple', $product_id );
            }
        }
    }
}

add_action( 'wp_loaded', 'fooevents_add_multiple_products_to_cart', 15 );

function fooevents_invoke_multiple_adds( $class_name, $methodName ) {
    if ( version_compare( phpversion(), '5.3', '<' ) ) {
        throw new Exception( 'PHP version does not support ReflectionClass::setAccessible()', __LINE__ );
    }

    $args = func_get_args();
    unset( $args[0], $args[1] );
    $reflection = new ReflectionClass( $class_name );
    $method     = $reflection->getMethod( $methodName );
    $method->setAccessible( true );

    $args = array_merge( array( $reflection ), $args );
    return call_user_func_array( array( $method, 'invoke' ), $args );
}




/**
 * Display variations in a table format.
 */

function woocommerce_variable_add_to_cart() {

    global $product, $post, $products, $products_multi_button;

    $woocommerce_events_type = get_post_meta( $post->ID, 'WooCommerceEventsType', true );

    // Comma separated list of product ID's that should display variations in table format. Leave empty to display all products ( e.g array() )

    if ( in_array( $post->ID, $products ) || empty( $products ) ) {

        // Set default in each input box to 0 instead of 1
        add_filter( 'woocommerce_quantity_input_args', 'fooevents_quantity_input_default', 10, 2 );

        $variations = find_valid_variations();

        // Check if the special 'price_grid' meta is set, if it is, load the default template.
        if ( get_post_meta( $post->ID, 'price_grid', true ) ) {

            // Enqueue variation scripts.
            wp_enqueue_script( 'wc-add-to-cart-variation' );

            // Load the template
            wc_get_template(
                'single-product/add-to-cart/variable.php',
                array(
                    'available_variations' => $product->get_available_variations(),
                    'attributes'           => $product->get_variation_attributes(),
                    'selected_attributes'  => $product->get_variation_default_attributes(),
                )
            );

            return;
        }

        // Custom template
        ?>
        <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%20type%3D%22text%2Fjavascript%22%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20JavaScript%20to%20build%20add%20to%20cart%20link%20based%20on%20quantity%20inputs%20and%20booking%20slots%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20is_bookable%20%3D%20false%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20jQuery(document).ready(function%20()%20%7B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20link_original%20%3D%20jQuery(%22%23add_to_cart_link%22).attr('data-href')%20%2B%20%22%3Fadd-to-cart%3D%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20link%20%3D%20%22%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20Check%20if%20booking%20slots%20should%20show%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20(%20jQuery(%20%22%23fooevents_bookings_slot_val__trans%22%20).length%20%7C%7C%20jQuery(%22%23fooevents_bookings_slot_date_val_trans%22).length%20)%20%7B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20booking_settings_link%20%3D%20%22%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20bookings_sid%20%3D%20%22%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20bookings_did%20%3D%20%22%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20bookings_method%20%3D%20%22%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20bookings_slot_date%20%3D%20%22%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20is_bookable%20%3D%20true%3B%0A%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20bookings_sid%20%3D%20jQuery(%22%23fooevents_bookings_slot_val__trans%22).val()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20bookings_did%20%3D%20jQuery(%22%23fooevents_bookings_date_val__trans%22).val()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20bookings_method%20%3D%20jQuery(%22%23fooevents_bookings_method%22).val()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20bookings_slot_date%20%3D%20jQuery(%22%23fooevents_bookings_slot_date_val_trans%22).val()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20jQuery(%22%23fooevents_bookings_slot_val__trans%22).change(function%20()%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20bookings_sid%20%3D%20jQuery(%22%23fooevents_bookings_slot_val__trans%22).val()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20updateLink(link%2Cbookings_sid%2Cbookings_did%2Cbookings_method%2Cbookings_slot_date)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20jQuery(%22%23fooevents_bookings_date_val__trans%22).change(function%20()%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20bookings_did%20%3D%20jQuery(%22%23fooevents_bookings_date_val__trans%22).val()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20updateLink(link%2Cbookings_sid%2Cbookings_did%2Cbookings_method%2Cbookings_slot_date)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D)%3B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20jQuery(%22%23fooevents_bookings_slot_date_val_trans%22).change(function%20()%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20bookings_slot_date%20%3D%20jQuery(%22%23fooevents_bookings_slot_date_val_trans%22).val()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20updateLink(link%2Cbookings_sid%2Cbookings_did%2Cbookings_method%2Cbookings_slot_date)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D)%3B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20jQuery(%22.quantity%20input%22).change(function%20()%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20link%20%3D%20link_original%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20no_quantity%20%3D%200%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20jQuery(%22.variations%20tr%22).each(function()%20%7B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20var_id%20%3D%20jQuery(this).find(%22input%5Bname%3Dvariation_id%5D%22).val()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20total%20%3D%20jQuery(this).find(%22.quantity%20input%22).val()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20(total%20%3E%200)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20no_quantity%2B%2B%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20link%20%2B%3D%20var_id%20%2B%20%22%3A%22%20%2B%20total%20%2B%20%22%2C%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D)%3B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20(no_quantity%20%3D%3D%200)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20jQuery(%22%23add_to_cart_link%22).removeAttr('href')%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20updateLink(link%2Cbookings_sid%2Cbookings_did%2Cbookings_method%2Cbookings_slot_date)%3B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%7D)%3B%0A%0A%20%20%20%20%20%20%20%20function%20updateLink(link%2Cbookings_sid%3D%22%22%2Cbookings_did%3D%22%22%2Cbookings_method%3D%22%22%2Cbookings_slot_date%3D%22%22)%7B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(is_bookable)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20(bookings_sid%20!%3D%20%22%22%20%26%26%20bookings_did%20!%3D%20%22%22%20%26%26%20bookings_sid%20!%3D%20undefined%20%26%26%20bookings_did%20!%3D%20undefined)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20jQuery(%22%23add_to_cart_link%22).attr('data-href'%2C%20link.slice(0%2C-1)%20%2B%20%22%26bookings_sid%3D%22%20%2B%20bookings_sid%20%2B%20%22%26bookings_did%3D%22%20%2B%20bookings_did%20%2B%20%22%26fooevents_bookings_method%3D%22%20%2B%20bookings_method)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20jQuery(%22%23add_to_cart_link%22).attr('href'%2C%20jQuery(%22%23add_to_cart_link%22).attr('data-href'))%3B%09%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20(bookings_slot_date%20!%3D%20%22%22%20%26%26%20bookings_slot_date%20!%3D%20undefined)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20jQuery(%22%23add_to_cart_link%22).attr('data-href'%2C%20link.slice(0%2C-1)%20%2B%20%22%26fooevents_bookings_method%3D%22%20%2B%20bookings_method%20%2B%20%22%26bookings_slot_date%3D%22%20%2B%20bookings_slot_date)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20jQuery(%22%23add_to_cart_link%22).attr('href'%2C%20jQuery(%22%23add_to_cart_link%22).attr('data-href'))%3B%09%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20jQuery(%22%23add_to_cart_link%22).attr('data-href'%2C%20link.slice(0%2C-1))%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20jQuery(%22%23add_to_cart_link%22).attr('data-href'%2C%20link.slice(0%2C-1))%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20jQuery(%22%23add_to_cart_link%22).attr('href'%2C%20jQuery(%22%23add_to_cart_link%22).attr('data-href'))%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="&lt;script&gt;" title="&lt;script&gt;" />
        <form class="cart"  action="<?php echo esc_url( $product->add_to_cart_url() ); ?>" method="post" enctype='multipart/form-data'>
            <table class="variations variations-grid" cellspacing="0">
                <tbody>

            <?php
            $variation = 0;
            foreach ( $variations as $key => $value ) {
                if ( ! $value['variation_is_visible'] ) {
                    continue;
                }
                if ( $variation != $value['variation_id'] ) {

                    if ( in_array( $post->ID, $products_multi_button ) ) {

                        ?>

                    <tr>
                        <td>
                        <?php

                        foreach ( $value['attributes'] as $key => $val ) {
                            $val = str_replace( array( '-', '_' ), ' ', $val );
                            printf( '<div class="attr attr-%s">%s</div>', $key, ucwords( $val ) );
                        }
                        ?>
                        </td>
                        <td>
                        <?php echo $value['price_html']; ?>
                        </td>
 
                        <?php if ( $value['is_in_stock'] ) { ?>
                            <form class="cart"  action="<?php echo esc_url( $product->add_to_cart_url() ); ?>" method="post" enctype='multipart/form-data'>
                                <td id="variation_<?php echo $value['variation_id']; ?>">
                                    <?php woocommerce_quantity_input(); ?>
                                    <?php
                                    $variation_minimum_quantity  = get_post_meta( $value['variation_id'], 'variation_minimum_allowed_quantity', true );
                                    $variation_maximum_quantity  = get_post_meta( $value['variation_id'], 'variation_maximum_allowed_quantity', true );
                                    $variation_group_of_quantity = get_post_meta( $value['variation_id'], 'variation_group_of_quantity', true );
                                    ?>
                                    <?php if ( isset( $variation_group_of_quantity ) ) { ?>
                                        <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%3E%0A%09%09%09%09%09%09%09%09%09%09jQuery(document).ready(function(%24)%7B%0A%09%09%09%09%09%09%09%09%09%09%09%24(%20%22%23variation_%3C%3Fphp%20echo%20%24value%5B'variation_id'%5D%3B%20%3F%3E%20.qty%22%20).attr(%20%22step%22%2C%20%3C%3Fphp%20echo%20%24variation_group_of_quantity%3B%20%3F%3E%20)%3B%0A%09%09%09%09%09%09%09%09%09%09%09%24(%20%22%23variation_%3C%3Fphp%20echo%20%24value%5B'variation_id'%5D%3B%20%3F%3E%20.qty%22%20).attr(%20%22value%22%2C%20%3C%3Fphp%20echo%20%24variation_group_of_quantity%3B%20%3F%3E%20)%3B%0A%09%09%09%09%09%09%09%09%09%09%09%24(%20%22%23variation_%3C%3Fphp%20echo%20%24value%5B'variation_id'%5D%3B%20%3F%3E%20.qty%22%20).attr(%20%22min%22%2C%20%3C%3Fphp%20echo%20%24variation_minimum_quantity%3B%20%3F%3E%20)%3B%0A%09%09%09%09%09%09%09%09%09%09%09%24(%20%22%23variation_%3C%3Fphp%20echo%20%24value%5B'variation_id'%5D%3B%20%3F%3E%20.qty%22%20).attr(%20%22max%22%2C%20%3C%3Fphp%20echo%20%24variation_maximum_quantity%3B%20%3F%3E%20)%3B%0A%09%09%09%09%09%09%09%09%09%09%7D)%3B%0A%09%09%09%09%09%09%09%09%09%09%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="&lt;script&gt;" title="&lt;script&gt;" />                                  
                                    <?php } ?>
                                </td>
                                <td>
                                    <?php
                                    if ( ! empty( $value['attributes'] ) ) {
                                        foreach ( $value['attributes'] as $attr_key => $attr_value ) {
                                            ?>
                                            <input type="hidden" name="<?php echo $attr_key; ?>" value="<?php echo $attr_value; ?>">
                                            <?php
                                        }
                                    }
                                    ?>
                                    <button type="submit" class="single_add_to_cart_button btn btn-primary"><span class="glyphicon glyphicon-tag"></span> Add to cart</button>
                                </td>
                                <input type="hidden" name="variation_id" value="<?php echo $value['variation_id']; ?>" />
                                <input type="hidden" name="product_id" value="<?php echo esc_attr( $post->ID ); ?>" />
                                <input type="hidden" name="add-to-cart" value="<?php echo esc_attr( $post->ID ); ?>" />
                            </form>
                            <?php } else { ?>
                                <td colspan="2">
                                    <p class="stock out-of-stock"><?php _e( 'This item is currently out of stock and unavailable.', 'woocommerce' ); ?></p>
                                </td>
                            <?php } ?>
                    </tr>
                  
                        <?php
                    } else {
                        ?>


                    
                    <tr>
                        <td style="display:table-cell">
                        <?php

                        foreach ( $value['attributes'] as $key => $val ) {
                            $val = str_replace( array( '-', '_' ), ' ', $val );
                            printf( '<div class="attr attr-%s">%s</div>', $key, ucwords( $val ) );
                        }
                        ?>
                        </td>
                        <td style="display:table-cell">
                        <?php echo $value['price_html']; ?>
                        </td>

                        <?php if ( $value['is_in_stock'] ) { ?>

                                <td id="variation_<?php echo $value['variation_id']; ?>" style="display:table-cell">
                                    <?php woocommerce_quantity_input(); ?>
                                    <?php
                                    $variation_minimum_quantity  = get_post_meta( $value['variation_id'], 'variation_minimum_allowed_quantity', true );
                                    $variation_maximum_quantity  = get_post_meta( $value['variation_id'], 'variation_maximum_allowed_quantity', true );
                                    $variation_group_of_quantity = get_post_meta( $value['variation_id'], 'variation_group_of_quantity', true );
                                    ?>
                                    <?php if ( isset( $variation_group_of_quantity ) ) { ?>
                                        <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%3E%0A%09%09%09%09%09%09%09%09%09%09jQuery(document).ready(function(%24)%7B%0A%09%09%09%09%09%09%09%09%09%09%09%24(%20%22%23variation_%3C%3Fphp%20echo%20%24value%5B'variation_id'%5D%3B%20%3F%3E%20.qty%22%20).attr(%20%22step%22%2C%20%3C%3Fphp%20echo%20%24variation_group_of_quantity%3B%20%3F%3E%20)%3B%0A%09%09%09%09%09%09%09%09%09%09%09%24(%20%22%23variation_%3C%3Fphp%20echo%20%24value%5B'variation_id'%5D%3B%20%3F%3E%20.qty%22%20).attr(%20%22value%22%2C%20%3C%3Fphp%20echo%20%24variation_group_of_quantity%3B%20%3F%3E%20)%3B%0A%09%09%09%09%09%09%09%09%09%09%09%24(%20%22%23variation_%3C%3Fphp%20echo%20%24value%5B'variation_id'%5D%3B%20%3F%3E%20.qty%22%20).attr(%20%22min%22%2C%20%3C%3Fphp%20echo%20%24variation_minimum_quantity%3B%20%3F%3E%20)%3B%0A%09%09%09%09%09%09%09%09%09%09%09%24(%20%22%23variation_%3C%3Fphp%20echo%20%24value%5B'variation_id'%5D%3B%20%3F%3E%20.qty%22%20).attr(%20%22max%22%2C%20%3C%3Fphp%20echo%20%24variation_maximum_quantity%3B%20%3F%3E%20)%3B%0A%09%09%09%09%09%09%09%09%09%09%7D)%3B%0A%09%09%09%09%09%09%09%09%09%09%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="&lt;script&gt;" title="&lt;script&gt;" />
                                    <?php } ?>
                                </td>
                                <td style="display:table-cell">
                                    <?php
                                    if ( ! empty( $value['attributes'] ) ) {
                                        foreach ( $value['attributes'] as $attr_key => $attr_value ) {
                                            ?>
                                            <input type="hidden" name="<?php echo $attr_key; ?>" value="<?php echo $attr_value; ?>">
                                            <?php
                                        }
                                    }
                                    ?>

                                </td>
                                <input type="hidden" name="variation_id" value="<?php echo $value['variation_id']; ?>" />
                                <input type="hidden" name="product_id" value="<?php echo esc_attr( $post->ID ); ?>" />
                                <input type="hidden" name="add-to-cart" value="<?php echo esc_attr( $post->ID ); ?>" />
                            </form>
                            <?php } else { ?>
                                <td colspan="2" style="display:table-cell">
                                    <p class="stock out-of-stock"><?php _e( 'This item is currently out of stock and unavailable.', 'woocommerce' ); ?></p>
                                </td>
                            <?php } ?>
                    </tr>
                                                <?php } ?>
                    <?php
                    $variation = $value['variation_id'];
                }
            }
            ?>
        
        </tbody>
        
            </table> 
            <?php
            if ( ! in_array( $post->ID, $products_multi_button ) ) {
                ?>
                <?php do_action( 'fooevents_output_booking_details' ); ?>
            <p class="form-row">
            <a id="add_to_cart_link" data-href="<?php echo esc_url( $product->add_to_cart_url() ); ?>" type="submit" class="single_add_to_cart_button btn btn-primary button alt wp-element-button"><span class="glyphicon glyphicon-tag"></span> Add to cart</a>
            </p>
            <?php } ?>
            </form>

        <?php
    } else {

        // Enqueue variation scripts.
        wp_enqueue_script( 'wc-add-to-cart-variation' );

        // Get Available variations?
        $get_variations = count( $product->get_children() ) <= apply_filters( 'woocommerce_ajax_variation_threshold', 30, $product );

        // Load the template.
        wc_get_template(
            'single-product/add-to-cart/variable.php',
            array(
                'available_variations' => $get_variations ? $product->get_available_variations() : false,
                'attributes'           => $product->get_variation_attributes(),
                'selected_attributes'  => $product->get_default_attributes(),
            )
        );

    }
}

function find_valid_variations() {
    global $product, $post;

    $variations   = $product->get_available_variations();
    $attributes   = $product->get_attributes();
    $new_variants = array();

    // Loop through all variations
    foreach ( $variations as $variation ) {

        // Peruse the attributes.

        // 1. If both are explicitly set, this is a valid variation
        // 2. If one is not set, that means any, and we must 'create' the rest.

        $valid = true; // so far
        foreach ( $attributes as $slug => $args ) {
            if ( array_key_exists( "attribute_$slug", $variation['attributes'] ) && ! empty( $variation['attributes'][ "attribute_$slug" ] ) ) {
                // Exists

            } else {
                // Not exists, create
                $valid = false; // it contains 'anys'
                // loop through all options for the 'ANY' attribute, and add each
                foreach ( explode( '|', $attributes[ $slug ]['value'] ) as $attribute ) {
                    $attribute                                      = trim( $attribute );
                    $new_variant                                    = $variation;
                    $new_variant['attributes'][ "attribute_$slug" ] = $attribute;
                    $new_variants[]                                 = $new_variant;
                }
            }
        }

        // This contains ALL set attributes, and is itself a 'valid' variation.
        if ( $valid ) {

            $new_variants[] = $variation;
        }
    }

    return $new_variants;
}

function fooevents_quantity_input_default( $args, $product ) {
    $args['input_value'] = 0;
    return $args;
}


/**
 * Adds booking slot dropdowns only to single product page if the event is "Bookable"
 */
function fooevents_add_booking_slots() {
    global $post, $products;
    $wc_product              = wc_get_product( $post->ID );
    $woocommerce_events_type = get_post_meta( $post->ID, 'WooCommerceEventsType', true );

    if ( is_plugin_active( 'fooevents_bookings/fooevents-bookings.php' ) || is_plugin_active_for_network( 'fooevents_bookings/fooevents-bookings.php' ) ) {

        if ( is_product() && $woocommerce_events_type == 'bookings' && ( in_array( $post->ID, $products ) || empty( $products ) ) && $wc_product->is_type( 'variable' ) ) {
            $fooevents_bookings = new Fooevents_Bookings();
            add_action( 'fooevents_output_booking_details', array( $fooevents_bookings, 'output_booking_fields_product' ) );
        }
    }
}
add_action( 'wp', 'fooevents_add_booking_slots' );

Aggiungere ai temi dei biglietti il supporto per gli orari di inizio e fine giornalieri #

A partire dalla versione 1.5.5 del FooEvents Multigiornaliero è possibile selezionare orari di inizio e fine diversi per ciascun giorno di un evento di più giorni. Il supporto per questa funzione è stato aggiunto anche a tutti i FooEvents Temi dei biglietti. Per favore seguire queste istruzioni per aggiornare un tema di ticket esistente. Se si utilizza un tema di ticket personalizzato e non si è in grado di sostituirlo con la versione aggiornata, aggiungere il seguente frammento di codice al tema di ticket per aggiungere il supporto per gli orari di inizio e fine. [php]

<!-- MULTI-DAY DETAILS -->
										

			<strong><?php printf( __( '%1$s %2$d: ', 'woocommerce-events' ), $ticket['dayTerm'], $x ); ?></strong>
			<?php echo esc_attr( $date ); ?><br /> 
			&lt;?php if ( ! empty( $ticket[&#039;WooCommerceEventsSelectDateHour&#039;][ $y ] ) &amp;&amp; ! empty( $ticket[&#039;WooCommerceEventsSelectDateMinutes&#039;][ $y ] ) : ?
				&lt;?php echo( isset( $ticket[&#039;WooCommerceEventsSelectDatePeriod&#039;][ $y ] ) ) ? &#039; &#039; . $ticket[&#039;WooCommerceEventsSelectDatePeriod&#039;][ $y ] : &#039;&#039;; ?
			
			
				&lt;?php echo( isset( $ticket[&#039;WooCommerceEventsSelectDatePeriodEnd&#039;][ $y ] ) ) ? &#039; &#039; . $ticket[&#039;WooCommerceEventsSelectDatePeriodEnd&#039;][ $y ] : &#039;&#039;; ?	
		<br />

I pulsanti predefiniti WooCommerce Aggiungi al carrello visualizzati sulle pagine degli elenchi dei negozi aggiungono automaticamente un prodotto al carrello e reindirizzano alla pagina del carrello. Quando si utilizzano le prenotazioni FooEvents, si potrebbe preferire incanalare l'utente attraverso la pagina del prodotto, in modo che possa prima effettuare una selezione di slot e orari di prenotazione prima di procedere alla pagina del carrello. Lo snippet seguente sostituisce il link al carrello con un link alla pagina del prodotto. In questo modo l'utente potrà effettuare la selezione di prenotazione appropriata nella pagina del prodotto prima di procedere al carrello o alla pagina di checkout.

/**
* @snippet Cambia il pulsante WooCommerce 'Aggiungi al carrello' in 'Visualizza prodotto'.
* @source https://www.wptechnic.com/?p=4615
* @autore Muhammad Tamzid
* @compatibile WC 4.3.1
*/
// Cambiare il pulsante WooCommerce "Aggiungi al carrello" in "Visualizza prodotto".
add_filter( 'woocommerce_loop_add_to_cart_link', 'wpt_custom_view_product_button', 10, 2 );
function wpt_custom_view_product_button( $button, $product ) {
    // Ignora i prodotti variabili
    if ( $product-&gt;is_type( 'variable' ) ) {
        return $button;
    }
    // Testo del pulsante qui
    $button_text = __( 'Book Ticket', 'woocommerce' );
    return '<a class="button wpt-custom-view-product-button" href="/it/' . $product->get_permalink() . '/">' . $button_text . '</a>';
}

Visualizzare la data dell'evento per gli eventi "singoli" nel carrello e nella pagina di checkout #

add_filter( 'woocommerce_cart_item_name', 'add_event_date_cart_checkout', 10, 3 );
function add_event_date_cart_checkout( $product_name, $cart_item, $cart_item_key ) {
	$product = $cart_item['data'];

	if ( $value = $product->get_meta( 'WooCommerceEventsDate' ) ) {
		$product_name .= '' . $value . '';
	}
	return $product_name;
}

Articoli

Tag , , , , , , , , , , , , , , , , , , ,