Skip to content

Instantly share code, notes, and snippets.

View assoscoupa's full-sized avatar
🏠
Working from home

Paris Koutroumanos assoscoupa

🏠
Working from home
View GitHub Profile
@assoscoupa
assoscoupa / gist:71833cc733cb6db91da48a32ff0c5368
Last active April 23, 2024 11:24
Add custom placeholders to WooCommerce email subject and body
/**
* @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 ) {
@assoscoupa
assoscoupa / gist:e52dac4bc62bce6114360e01baaa7231
Last active March 26, 2023 20:49 — forked from shubhw12/gist:12f204c61b7d5854507a124676159816
Display tags below post in Astra Theme
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(){
@assoscoupa
assoscoupa / Add_Read_More_in_WooCommerce_Category_Description.php
Last active June 4, 2021 11:06
Add Read More in WooCommerce Category Description
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);
@assoscoupa
assoscoupa / wc-add-order-notes-to-admin-emails
Created April 21, 2021 17:11 — forked from vanbo/wc-add-order-notes-to-admin-emails
WooCommerce: Add Order notes to admin emails
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
@assoscoupa
assoscoupa / wp-paths.php
Created April 19, 2021 06:13 — forked from Yiannistaos/wp-paths.php
Determining Plugin and Content Directories in WordPress (Cheat Sheet)
<?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/
@assoscoupa
assoscoupa / functions.php
Created April 17, 2021 07:52 — forked from premanshup/functions.php
Change the default row and col value of Textarea for comment in Astra
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;
}
@assoscoupa
assoscoupa / wc-exclude-product-category-from-shop-page.php
Created March 13, 2021 21:01 — forked from stuartduff/wc-exclude-product-category-from-shop-page.php
This snippet will exclude all products from any categories which you choose from displaying on the WooCommerce Shop page.
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'
);
@assoscoupa
assoscoupa / woocommerce_remove_address_2_field
Last active January 6, 2021 22:48
WooCommerce How To Remove Address Line 2
<?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;
@assoscoupa
assoscoupa / woocommerce_admin_disabled.php
Created January 3, 2021 12:36
Disable WooCommerce Analytics
<?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' );
@assoscoupa
assoscoupa / Adding SKU to Woo shop page
Last active October 26, 2020 17:17
Adding SKU to Woo shop page
/* 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);