Okay
  Public Ticket #2456901
Event with variable product for checkout
Closed

Comments

  •  1
    Matt started the conversation

    Hello,

    In the event example mentioned above, the product attached to this event is variable. There are options the event attendee can pick that will change the price.

    Is it possible to change the way the event is shown on the product so that the add-on fields being collected for the product are visible?

    Or, as an alternative, could the button below the event go to the product screen for more details rather than adding immediately to the cart?

  •  877
    Zhivko replied

    Hi,

    Shop section is planned for redesign mainly because of the variable products.

    Currently I can provide you with alternative to open the product page instead of add to cart button.

    Insert the following code in your theme / child-theme functions.php file:

    /**
     * STEC MOD:
     * 
     * Variable products "Add to Cart" button is replaced by "View Product" 
     * on click redirects to product page
     */
    add_action('wp_head', function() {
        global $post;     if (!is_a($post, 'WP_Post') || (!has_shortcode($post->post_content, 'stachethemes_ec') && 'stec_event' !== $post->post_type)) {
            return;
        }
        ?>
        <style>
            .stec-view-product-btn {
                white-space: nowrap;
            }
            
            
            .stec-layout-single-media-small .stec-view-product-btn,
            .stec-media-small .stec-view-product-btn {
                margin-top: 20px;
            }
        </style>
        <?php
    }); add_action('wp_footer', function() {     global $post;     if (!is_a($post, 'WP_Post') || (!has_shortcode($post->post_content, 'stachethemes_ec') && 'stec_event' !== $post->post_type)) {
            return;
        }
        ?>
        <script type="text/javascript">
            (function ($) {             // In calendar page
                $(document).on('onEventToggleOpen', function (e, data) {
                    var product = data.$instance.find('.stec-layout-event-inner-shop-products .stec-layout-event-inner-shop-product');                 $.each(product, function () {                     let $product, $buyBtn, isVariable, link;                     $product = $(this);                     if ($product.find('.stec-view-product-btn').length > 0) {
                            return true; // continue;
                        }                     $buyBtn = $product.children('div').last();
                        isVariable = $product.find('.stec-layout-event-inner-shop-product-price > a').length > 0 ? true : false;
                        link = $product.find('.stec-layout-event-inner-shop-product-desc a').attr('href');                     if (isVariable) {
                            $('<p class="stec-view-product-btn"><a class="stec-style-button stec-layout-event-btn-fontandcolor" target="_BLANK" href="' + link + '">View Product</a></p>').appendTo($product);
                            $buyBtn.remove();
                        }                 });
                });
                
                // Single page
                if ($('.stec-layout-single').length > 0) {                 var products = $('.stec-layout-single-shop-product');                 $.each(products, function () {                     let $product, $buyBtn, isVariable, link;                     $product = $(this);                     if ($product.find('.stec-view-product-btn').length > 0) {
                            return true; // continue;
                        }                     $buyBtn = $product.children('div').last();
                        isVariable = $product.find('.stec-layout-single-shop-product-price > a').length > 0 ? true : false;
                        link = $product.find('.stec-layout-single-shop-product-price a').attr('href');                     if (isVariable) {
                            $('<p class="stec-view-product-btn"><a class="stec-layout-single-button-style stec-layout-event-btn-fontandcolor" target="_BLANK" href="' + link + '">View Product</a></p>').appendTo($product);
                            $buyBtn.remove();
                        }
                    });             }         })(window.jQuery);
        </script>
        <?php
    });

    Stachethemes Developer