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
/* Variation drop down will need to be styled to match theme. Use this as a starting point. */ | |
li.product-type-variable td { | |
float: left; | |
} | |
#main li.product input { | |
float: none; | |
} |
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
// Hide Products Until A Specific Product Is Purchased | |
function ghostie_pepper_until_purchase( $purchasing_product_id ) { | |
// Check if user has purchased the purchasing product | |
if ( wc_customer_bought_product( get_current_user_id(), $purchasing_product_id ) ) { | |
return; | |
} | |
// If not, hide the specified products | |
$products_to_hide = array( 123, 456, 789 ); // replace with your product IDs |
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
// Disable Order Processing Email For Virtual Products | |
add_action( 'woocommerce_checkout_process', 'virtual_products_that_dont_annoy_customers' ); | |
function virtual_products_that_dont_annoy_customers() { | |
// Check if the cart contains virtual products only | |
$virtual_products_only = true; | |
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { | |
if ( ! $cart_item['data']->is_virtual() ) { |
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
// Auto-complete virtual orders if payment is completed by u/acephaliax | |
function auto_complete_virtual_orders($order_id) { | |
if (!$order_id) { | |
return; | |
} | |
// Get the order object | |
$order = wc_get_order($order_id); | |
// Check if the order contains virtual products |
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
// Wordpress Greet Logged In User Shortcode | |
function detective_otter_found_you( $atts ) { | |
global $current_user, $user_login; | |
get_currentuserinfo(); | |
if ($user_login) { | |
$display_name = '<a href="' . get_permalink( get_option('woocommerce_myaccount_page_id') ) . '">' . $current_user->display_name . '</a>'; | |
return 'Hi ' . $display_name . ','; //Change Hi to desired greeting. | |
} 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
Change #searchform and #search to match your form fields. |
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
/* Truncate product titles */ | |
.woocommerce ul.products li.product .woocommerce-loop-product__title, | |
.woocommerce-page ul.products li.product .woocommerce-loop-product__title { | |
white-space: nowrap; | |
overflow: hidden; | |
text-overflow: ellipsis; | |
max-width: 100%; | |
} | |
/* Expand truncated product titles on hover or focus */ |
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( 'the_title', 'shorten_woo_product_title', 10, 2 ); | |
function shorten_woo_product_title( $title, $id ) { | |
if ( ! is_singular( array( 'product' ) ) && get_post_type( $id ) === 'product' && strlen( $title ) > 30 ) { | |
return substr( $title, 0, 30) . '…'; // change last number to the number of characters you want | |
} else { | |
return $title; | |
} | |
} |
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 checkout field | |
add_action('woocommerce_after_order_notes', 'howd_you_find_us_bro'); | |
function howd_you_find_us_bro($checkout) { | |
echo '<div id="hdfoamb"><h3>' . __('How did you find my business?') . '</h3>'; | |
woocommerce_form_field( 'customer_acquisition', array( | |
'type' => 'textarea', | |
'class' => array('my-field-class form-row-wide'), |
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
Use snippet wcrtpf2omi2.php if you don't want the snippet to handle redirection for single products. Replace the $thankyou_page_url and $thankyou_multiple_page_url variables with the URLs of your custom thank you pages as needed. |
OlderNewer