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
/** | |
* @snippet Add custom placeholders to WooCommerce email subject and body | |
* @author Paris Koutroumanos | |
* @website https://www.qwerty.gr/ | |
* @compatible WooCommerce 3.2+ | |
* Read more https://wpauthors.com/blog/how-to-add-custom-placeholders-to-woocommerce-email-subject/ | |
* Read more https://www.businessbloomer.com/woocommerce-get-logged-username/ | |
*/ | |
function qwerty_filter_email_format_string( $string, $email ) { |
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( 'astra_post_tags', 'remove_tags_callback' ); | |
function remove_tags_callback(){ | |
return ' '; | |
} | |
add_action( 'astra_entry_after' , 'add_tags_callback'); | |
function add_tags_callback(){ |
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_main_content', 'qwerty_gr_woocommerce_after_main_content' ); | |
function qwerty_gr_woocommerce_after_main_content() { | |
if ( is_product_category() ){ | |
wc_enqueue_js(' | |
var show_char = 60; | |
var ellipses = "... "; | |
var content = $(".term-description").html(); | |
if (content.length > show_char) { | |
var a = content.substr(0, show_char); |
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_meta', 'woo_add_order_notes_to_email', 10, 3 ); | |
function woo_add_order_notes_to_email( $order, $sent_to_admin = true, $plain_text = false ) { | |
// You want to send those only to the Admin | |
if ( ! $sent_to_admin ) { | |
return; | |
} | |
// You can also check which email you are sending, by checking the order status | |
// Optional, comment it out, if not needed |
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
<?php | |
echo "<h1>Determining Plugin and Content Directories in WordPress (Cheat Sheet)</h1>"; | |
# PLUGINS | |
echo "<h2>PLUGINS</h2>"; | |
echo plugins_url(). "<br>"; # http://wordpress.test/wp-content/plugins | |
echo plugins_url('akismet'). "<br>"; # http://wordpress.test/wp-content/plugins/akismet | |
echo plugins_url( 'assets/js/myscript.js', __FILE__ ). "<br>"; # http://wordpress.test/wp-content/plugins/assets/js/myscript.js | |
echo plugin_dir_url('') . "<br>"; # http://wordpress.test/wp-content/plugins/ |
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( 'astra_comment_form_default_markup', 'astra_edit_comment_textarea_row_col' ); | |
function astra_edit_comment_textarea_row_col( $args ) { | |
$args['comment_field'] = '<div class="ast-row comment-textarea"><fieldset class="comment-form-comment"><div class="comment-form-textarea ast-col-lg-12"><label for="comment" class="screen-reader-text">' . esc_html( astra_default_strings( 'string-comment-label-message', false ) ) . '</label><textarea id="comment" name="comment" placeholder="' . esc_attr( astra_default_strings( 'string-comment-label-message', false ) ) . '" cols="5" rows="5" aria-required="true"></textarea></div></fieldset></div>'; | |
return $args; | |
} |
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 custom_pre_get_posts_query( $q ) { | |
$tax_query = (array) $q->get( 'tax_query' ); | |
$tax_query[] = array( | |
'taxonomy' => 'product_cat', | |
'field' => 'slug', | |
'terms' => array( 'clothing' ), // Don't display products in the clothing category on the shop page. | |
'operator' => 'NOT IN' | |
); |
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
<?php | |
// Do NOT include the opening php tag. | |
// Place in your theme's functions.php file | |
// Set address 2 to not required | |
add_filter('woocommerce_checkout_fields', 'unrequire_address_2_checkout_fields' ); | |
function unrequire_address_2_checkout_fields( $fields ) { | |
$fields['billing']['billing_address_2']['required'] = false; | |
$fields['shipping']['shipping_address_2']['required'] = 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
<?php | |
/** | |
* Plugin Name: Disable WooCommerce Admin | |
* Description: This plugin disables the new WooCommerce Admin package in WooCommerce. | |
* Version: 1.0 | |
*/ | |
add_filter( 'woocommerce_admin_disabled', '__return_true' ); |
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
/* Adding SKU to shop page */ | |
function qwerty_gr_custom_shop_item() { | |
global $post, $product; | |
/* product sku */ | |
echo '<p>SKU: '.$product->get_sku().'</p>'; | |
} | |
add_action( 'woocommerce_after_shop_loop_item', 'qwerty_gr_custom_shop_item', 5); |
NewerOlder