/* 
Theme Name: Hello Elementor Child
Theme URI: https://github.com/elementor/hello-theme-child/
Description: Hello Elementor Child is a child theme of Hello Elementor, created by Elementor team
Author: Elementor Team
Author URI: https://elementor.com/
Template: hello-elementor
Version: 2.0.0
Text Domain: hello-elementor-child
License: GNU General Public License v3 or later.
License URI: https://www.gnu.org/licenses/gpl-3.0.html
Tags: flexible-header, custom-colors, custom-menu, custom-logo, editor-style, featured-images, rtl-language-support, threaded-comments, translation-ready
*/

/* Add your custom styles here */

#fooevents_seating_dialog .fooevents_seating_chart_view_row_name,
#fooevents_seating_dialog .fooevents_seating_chart_view_row {
  text-align: center;
}

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 ) {
    if (is_product_category() || is_shop()) {
        $button_text = $product->add_to_cart_text();
        $button_link = $product->get_permalink();
        $button = '<a class="button" href="' . $button_link . '">' . $button_text . '</a>';
        return $button;
    }
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/**
 * Display variations in a table format.
 */
 
function woocommerce_variable_add_to_cart() {
 
    global $product, $post;
 
    // Enter a comma separated list of product ID's that should display variations in table format. Leave empty to display all product ( e.g array() )
    $products = array( ); 
 
    if ( in_array( $post->ID, $products ) || empty( $products ) ) {
 
        $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;
        }
        // Cool, lets do our own template!
        ?>
            <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'] ) {
 
                    ?>
 
                    <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
                    $variation = $value['variation_id'];
                }
            }
            ?>
            </tbody>
            </table>
 
 
        <?php
    } else {
 
        // 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;
    }
}
 
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;
}