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
// Remove the tabs from woocommerce - posted by Robin Scott of Silicon Dales @ https://silicondales.com/tutorials/woocommerce-tutorials/remove-tab-woocommerce/ | |
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 ); | |
function woo_remove_product_tabs( $tabs ) { | |
unset( $tabs['description'] ); // Remove the description tab | |
unset( $tabs['reviews'] ); // Remove the reviews tab | |
unset( $tabs['additional_information'] ); // Remove the additional information tab | |
return $tabs; |
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
// Automatically complete woocommerce orders on successful payment (skip "processing") - Robin Scott for SiliconDales.com | |
add_action( 'woocommerce_thankyou', 'sd_woocommerce_auto_complete_order' ); | |
function sd_woocommerce_auto_complete_order( $order_id ) { | |
if ( ! $order_id ) { | |
return; | |
} | |
$order = wc_get_order( $order_id ); | |
$order->update_status( 'completed' ); | |
} |
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 this to functions.php, a custom plugin, or a snippets plugin to remove the description tab in woocommerce | |
// by Robin Scott of Silicon Dales - full info at https://silicondales.com/tutorials/woocommerce-tutorials/remove-description-tab-woocommerce/ | |
add_filter( 'woocommerce_product_tabs', 'sd_remove_product_tabs', 98 ); | |
function sd_remove_product_tabs( $tabs ) { | |
unset( $tabs['description'] ); | |
return $tabs; | |
} |
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
// Robin Scott added this here for use in SiliconDales.com, but the snippet comes from Gravity Forms docs, here: https://docs.gravityforms.com/gform_export_fields/ | |
add_filter( 'gform_export_fields', function ( $form ) { | |
// only limit the fields available for export form form ID 3 | |
if ( $form['id'] == 3 ) { | |
// array of field IDs I never want to see on the export page | |
$fields_to_remove = array( | |
'payment_amount', | |
'payment_date', | |
'payment_status', | |
'transaction_id', |
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
// Remove unwanted fields from Gravity Forms export - updated by Robin Scott of Silicon Dales | |
add_filter( 'gform_export_fields', function ( $form ) { | |
// array of field IDs I never want to see on the export page | |
$fields_to_remove = array( | |
'payment_amount', | |
'payment_date', | |
'payment_status', | |
'transaction_id', | |
'user_agent', | |
'ip', |
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
//this gist will hide Yoast breadcrumbs on the blog front page (the home page if you made this a page) | |
// see https://silicondales.com/tutorials/wordpress-tutorials/code-hide-content-front-page-wordpress/ | |
<?php if( !is_front_page() ) { | |
if ( function_exists('yoast_breadcrumb') ) { | |
yoast_breadcrumb(' | |
<p id="breadcrumbs">','</p> | |
'); | |
} | |
} | |
?> |
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
// the gist below will hide stuff on the frontpage in wordpress, when added to a theme template file... see https://silicondales.com/tutorials/wordpress-tutorials/code-hide-content-front-page-wordpress/ | |
<?php if( !is_front_page() ) {?> | |
// hide this stuff | |
<?php } ?> |
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
// Added by Robin Scott of Silicon Dales here to demonstrate My Account / login links: https://silicondales.com/tutorials/woocommerce/display-woocommerce-account-page-link-logged-users-login-register-link-not-logged/ | |
<?php if ( is_user_logged_in() ) { ?> | |
<a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>" title="<?php _e('My Account','woocommerce'); ?>"><?php _e('My Account','woocommerce'); ?></a> | |
<?php } | |
else { ?> | |
<a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>" title="<?php _e('Login / Register','woocommerce'); ?>"><?php _e('Login / Register','woocommerce'); ?></a> | |
<?php } ?> |
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
// posted by Robin Scott https://silicondales.com/tutorials/woocommerce-tutorials/woocommerce-tutorial-allow-users-purchase-items/ - prevent user adding item to cart if they bought it before... | |
add_filter('woocommerce_add_to_cart_validation','sd_bought_before_woocommerce_add_to_cart_validation',20, 2); | |
function sd_bought_before_woocommerce_add_to_cart_validation($valid, $product_id){ | |
$current_user = wp_get_current_user(); | |
if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id)) { | |
wc_add_notice( __( 'ERROR MESSAGE GOES HERE SORRY YOU CANNOT BUY ANYTHING TWICE OKAY!!', 'woocommerce' ), 'error' ); | |
$valid = false; | |
} | |
return $valid; | |
} |
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 a shortcode to dispay [now_time] for the time in Europe/London - by Robin Scott of Silicon Dales | |
function sd_now_time_formated($atts) { | |
date_default_timezone_set("Europe/London"); | |
$i = date('g:i A'); | |
return $i; | |
} | |
add_shortcode('now_time', 'sd_now_time_formated'); |