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 conditionally_hide_local_pickup( $rates, $package ) { | |
$minimum_amount = 50; // Set your minimum order amount here | |
// Get the cart total | |
$cart_total = WC()->cart->get_displayed_subtotal(); | |
// Check if cart total is less than the minimum amount | |
if ( $cart_total < $minimum_amount ) { | |
// Loop through the available shipping methods | |
foreach ( $rates as $rate_id => $rate ) { |
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 €40 deposit to the cart based on product ID | |
add_action('woocommerce_cart_calculate_fees', 'add_deposit_fee'); | |
function add_deposit_fee() { | |
if (is_admin() && !defined('DOING_AJAX')) return; | |
$deposit_fee = 40; // Deposit amount | |
$product_ids = array(391); // Replace with your product IDs | |
$add_deposit = false; |
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', 'custom_add_customer_groups'); | |
function custom_add_customer_groups() { | |
add_role('group1', __('Group 1'), array()); | |
add_role('group2', __('Group 2'), array()); | |
add_role('group3', __('Group 3'), array()); | |
} |
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_after_single_product_summary', 'display_on_sale_products_by_brand', 15 ); | |
function display_on_sale_products_by_brand() { | |
global $post; | |
// Get the brands of the current product | |
$brands = wp_get_post_terms( $post->ID, 'brand' ); | |
if ( ! empty( $brands ) && ! is_wp_error( $brands ) ) { | |
foreach ( $brands as $brand ) { |
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 wc_placeholder_img_src( $size = 'woocommerce_thumbnail' ) { | |
$src = WC()->plugin_url() . '/assets/images/placeholder.png'; | |
$placeholder_image = get_option( 'woocommerce_placeholder_image', 0 ); | |
if ( ! empty( $placeholder_image ) ) { | |
if ( is_numeric( $placeholder_image ) ) { | |
$image = wp_get_attachment_image_src( $placeholder_image, $size ); | |
if ( ! empty( $image[0] ) ) { | |
$src = $image[0]; |
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 display_custom_products_before_category() { | |
// Define the product IDs you want to display | |
$custom_product_ids = array(123, 456, 789); // Replace with your product IDs | |
// Set the date range to display the custom products (for 1 month) | |
$start_date = '2024-05-01'; // Start date in 'Y-m-d' format | |
$end_date = '2024-06-01'; // End date in 'Y-m-d' format | |
$current_date = date('Y-m-d'); | |
// Check if current date is within the range |
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
genesis_register_sidebar( array( | |
'id' => 'slider', | |
'name' => __( 'Slider', 'agentpress' ), | |
'description' => __( 'This is the slider widget area.', 'agentpress' ), | |
) ); | |
add_action( 'genesis_before_content_sidebar_wrap', 'slider_before_content', 5 ); | |
function slider_before_content() { | |
if ( is_front_page() ) |
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( 'genesis_after_header', 'hook_slider' ); | |
function hook_slider() { | |
if ( is_front_page() ) { ?> | |
<div class="carousel-slider"> | |
<div class="slide"><img src="http://placehold.it/350x150&text=Slide1"></div> | |
<div class="slide"><img src="http://placehold.it/350x150&text=Slide2"></div> | |
<div class="slide"><img src="http://placehold.it/350x150&text=Slide3"></div> | |
<div class="slide"><img src="http://placehold.it/350x150&text=Slide4"></div> | |
<div class="slide"><img src="http://placehold.it/350x150&text=Slide5"></div> | |
<div class="slide"><img src="http://placehold.it/350x150&text=Slide6"></div> |
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_product_add_to_cart_text', 'custom_combined_add_to_cart_button_text', 10, 2); | |
add_filter('woocommerce_product_single_add_to_cart_text', 'custom_combined_add_to_cart_button_text', 10, 2); | |
function custom_combined_add_to_cart_button_text($text, $product) { | |
if ( ! $product->is_in_stock()) { | |
return __('Out of Stock', 'woocommerce'); | |
} else { |
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 apply_shipping_based_discounts() { | |
$chosen_shipping_methods = WC()->session->get('chosen_shipping_methods'); | |
$chosen_shipping_method = $chosen_shipping_methods[0]; | |
$discount = 0; | |
if ($chosen_shipping_method === 'free_shipping') { | |
$discount = 10; // Discount for free shipping | |
} elseif ($chosen_shipping_method === 'flat_rate') { | |
$discount = 5; // Discount for flat rate | |
} elseif ($chosen_shipping_method === 'local_pickup') { |
NewerOlder