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
// Redirect to homepage after logout | |
function custom_logout_redirect() { | |
wp_redirect(home_url()); | |
exit(); | |
} | |
add_action('wp_logout', 'custom_logout_redirect'); |
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
/** | |
* Prevent shipping to PO box addresses in WooCommerce | |
*/ | |
add_action('woocommerce_after_checkout_validation', 'deny_pobox_postcode'); | |
function deny_pobox_postcode($posted) { | |
// Determine if we are checking the shipping or billing address | |
$address = isset($posted['shipping_address_1']) ? $posted['shipping_address_1'] : $posted['billing_address_1']; | |
$postcode = isset($posted['shipping_postcode']) ? $posted['shipping_postcode'] : $posted['billing_postcode']; |
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
// Allow wholesale customers to view all products | |
function allow_wholesale_customer_view_all_products($query) { | |
// Check if the user has the "wholesale_customer" role and if it's the main query | |
if (current_user_can('wholesale_customer') && $query->is_main_query()) { | |
// Set the query to retrieve products only | |
$query->set('post_type', 'product'); | |
// Set the post status to include both published and private products | |
$query->set('post_status', ['publish', 'private']); | |
// Ignore sticky posts | |
$query->set('ignore_sticky_posts', 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
add_filter( 'jetpack_get_default_modules', 'disable_all_jetpack_modules_except_woocommerce' ); | |
function disable_all_jetpack_modules_except_woocommerce( $modules ) { | |
// List of Jetpack modules needed for WooCommerce App. | |
$required_modules = array( | |
'json-api', // Required for the WooCommerce Mobile App. | |
// Add other modules as needed. | |
); | |
// Disable all modules except those in the list above. |
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 this code to your child theme's functions.php file | |
add_filter( 'woocommerce_get_price_html', 'hide_zero_price', 10, 2 ); | |
/** | |
* Hide price if it is zero | |
* | |
* @param string $price The price (HTML formatted). | |
* @param WC_Product $product The product object. | |
* @return string |
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 an action on cart evaluation | |
add_action( 'woocommerce_check_cart_items', 'limit_cart_items_for_specific_role' ); | |
function limit_cart_items_for_specific_role() { | |
// The user role to check against | |
$user_role_to_check = 'subscriber'; | |
// The item limit | |
$item_limit = 3; | |
// Get the current user |
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
/** | |
* This function checks if an order has a total of zero (free), and if so, stops the "Completed order" email from being sent. | |
* | |
* @param bool $is_enabled - Original state of the email (enabled/disabled) | |
* @param WC_Order $order - The order object for which the email is being sent | |
* @return bool - Modified state of the email (enabled/disabled) | |
*/ | |
function disable_free_order_completed_email( $is_enabled, $order ) { | |
// Check if the order total is zero | |
if ( 0 == $order->get_total() ) { |
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
// Remove default related products function | |
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 ); | |
// Add our custom related products function to the same hook | |
add_action( 'woocommerce_after_single_product_summary', 'custom_related_products', 20 ); | |
function custom_related_products() { | |
// Use global $product object | |
global $product; | |
// Prepare the arguments for WP_Query |
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
<style> | |
.staffer img { | |
clear: both; | |
display: block; | |
margin: 0 auto; | |
-webkit-mask-image: url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgNjAwIDYwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNNDU0LjUgMTM3LjZDNTIwIDIwMC4xIDU5OC4yIDI2OC41IDYwMCAzNDMuOGMxLjYgNzUuMy03My40IDE1Ny41LTE3MS40IDIwNy41LTk4IDQ5LjktMjE4LjkgNjcuOC0yOTcgMjMuMi03Ny45LTQ0LjQtMTEyLjgtMTUxLjEtMTI2LTI1MFMuOSAxMzQuNyA1MSA3NS42YzQ5LjktNTkuMSAxNDEuMy04Ni40IDIxMy4zLTcxLjdDMzM2LjMgMTguNiAzODkgNzUgNDU0LjUgMTM3LjZ6Ii8+PC9zdmc+); | |
mask-image: url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgNjAwIDYwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNNDU0LjUgMTM3LjZDNTIwIDIwMC4xIDU5OC4yIDI2OC41IDYwMCAzNDMuOGMxLjYgNzUuMy03My40IDE1Ny41LTE3MS40IDIwNy41LTk4IDQ5LjktMjE4LjkgNjcuOC0yOTcgMjMuMi03Ny45LTQ0LjQtMTEyLjgtMTUxLjEtMTI2LTI1MFMuOSAxMzQuNyA1MSA3NS42YzQ5LjktNTkuMSAxNDEuMy04Ni40IDIxMy4zLTcxLjdDMzM2LjMgMTguNiAzODkgNzUgNDU0LjUgMTM3LjZ6Ii8+PC9zdmc+); | |
} | |
</style> |
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
// Function to add Custom Post Type. | |
function olympus_custom_post_type() | |
{ | |
// Register the doc post type | |
register_post_type( 'docs', array( | |
'labels' => array( | |
'name' => esc_html__( 'Documentation', 'olympus' ), | |
'singular_name' => esc_html__( 'Document', 'olympus' ), | |
'add_new' => esc_html__( 'Add New', 'olympus' ), |
NewerOlder