This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Schedule the function to run hourly | |
| add_action('init', 'schedule_update_random_free_product'); | |
| // Function to select and update a random free product | |
| function update_random_free_product() { | |
| $random_product_id = get_random_free_product(); | |
| if ($random_product_id) { | |
| update_option('random_free_product_id', $random_product_id); | |
| update_option('random_free_product_date', current_time('Y-m-d')); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_filter( 'woocommerce_available_variation', 'unset_variation_attribute', 10, 3 ); | |
| function unset_variation_attribute( $data, $product, $variation ) { | |
| // Define the attribute name you want to hide (e.g., "Size") | |
| $attribute_to_hide = 'Size'; | |
| // Unset the attribute if it exists in the variation data | |
| if (isset($data['attributes']['attribute_' . sanitize_title($attribute_to_hide)])) { | |
| unset($data['attributes']['attribute_' . sanitize_title($attribute_to_hide)]); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| && in_array( 'administrator', (array) $user->roles ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action( 'woocommerce_before_single_product_summary', 'hook_field' ); | |
| function hook_field() { | |
| if ( is_product() and is_single('15412') ) { | |
| echo get_post_meta( get_the_ID(), 'product_field', true ); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $message_one = 'Message 1'; | |
| $message_two = 'Message 2'; | |
| $custom_message = has_term( 'demo', 'product_cat' ) ? $message_one : $message_two; | |
| return $custom_message; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if ( has_term( 'demo', 'product_cat' ) ) | |
| return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action('woocommerce_after_shop_loop_item_title', 'hook_cat_link'); | |
| function hook_cat_link() { | |
| global $product; | |
| echo wc_get_product_category_list( $product->get_id(), ', ', '<span class="posted_in">' . _n( '', '', count( $product->get_category_ids() ), 'woocommerce' ) . ' ', '</span>' ); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $result = $customer || current_user_can('administrator') ? the_content() : $not_customer; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(document).ready(function(){ | |
| $('a.woocommerce-product-gallery__trigger').click(function(){ | |
| window.open(this.href); | |
| return false; | |
| }); | |
| }); |