This file contains 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_email_order_details', 'add_custom_fields_to_order_email', 10, 4); | |
function add_custom_fields_to_order_email($order, $sent_to_admin, $plain_text, $email) { | |
foreach ($order->get_items() as $item_id => $item) { | |
$product_id = $item->get_product_id(); | |
$expiration_date = get_post_meta($product_id, '_expiration_date', true); | |
if ( ! empty( $expiration_date ) ) { |
This file contains 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
function exclude_products_from_search($query) { | |
if (is_admin() || !$query->is_main_query()) { | |
return; | |
} | |
if ($query->is_search) { | |
$query->set('post_type', array('post', 'page')); // Exclude products from search results | |
} | |
} |
This file contains 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 custom field to product general settings metabox | |
function custom_product_general_fields() { | |
global $woocommerce, $post; | |
echo '<div class="options_group">'; | |
// Custom field | |
woocommerce_wp_textarea_input( | |
array( | |
'id' => '_custom_product_description', |
This file contains 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_cart', 'apply_discount_and_add_free_product'); | |
function apply_discount_and_add_free_product() { | |
global $woocommerce; | |
if (WC()->cart->has_discount('30OFF')) { | |
$free_product_id = 14646; | |
$quantity = 1; | |
WC()->cart->add_to_cart($free_product_id, $quantity); |
This file contains 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
/* Media query for mobile screens */ | |
@media only screen and (max-width: 767px) { | |
/* Adjust styles for filter links on mobile screens */ | |
.isotope-filter a { | |
display: block; /* Make links display as block elements */ | |
margin: 0 0 10px; /* Add margin below each link */ | |
width: 100%; /* Make links take up full width */ | |
} | |
} |
This file contains 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
register_taxonomy( 'portfolio-type', 'portfolio', | |
array( | |
'labels' => array( | |
'name' => _x( 'Portfolio Types', 'taxonomy general name' , 'genesis-portfolio-pro' ), | |
'singular_name' => _x( 'Portfolio Type' , 'taxonomy singular name', 'genesis-portfolio-pro' ), | |
'search_items' => __( 'Search Portfolio Types' , 'genesis-portfolio-pro' ), | |
'popular_items' => __( 'Popular Portfolio Types' , 'genesis-portfolio-pro' ), | |
'all_items' => __( 'All Types' , 'genesis-portfolio-pro' ), | |
'edit_item' => __( 'Edit Portfolio Type' , 'genesis-portfolio-pro' ), | |
'update_item' => __( 'Update Portfolio Type' , 'genesis-portfolio-pro' ), |
This file contains 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('init', 'assign_random_free_product'); | |
function assign_random_free_product() { | |
$today = date('Y-m-d'); | |
$assigned_product_date = get_option('random_free_product_date'); | |
if ( $today != $assigned_product_date ) { | |
$random_product_id = get_random_free_product(); |
This file contains 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 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 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 ) |