Skip to content

Instantly share code, notes, and snippets.

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

Filipe Seabra filipecsweb

🏠
Working from home
View GitHub Profile
@filipecsweb
filipecsweb / functions.php
Last active April 14, 2024 18:09
WooCommerce shortcode to output product categories randomly
<?php
/**
* Create the new WooCommerce shortcode [random_product_categories] to output product categories randomly.
* Based on [product_categories] (/plugins/woocommerce/includes/class-wc-shortcodes.php).
*
* This new shortcode accepts all attributes used by [product_categories], except 'orderby' and 'order', of course.
* See more at @link https://woocommerce.com/document/woocommerce-shortcodes/.
*
* @param array $atts User defined attributes in shortcode tag.
*/
@filipecsweb
filipecsweb / functions.php
Last active November 2, 2017 07:17
Display Simple Product SKU, in WooCommerce loop pages, before item name
<?php
/**
* Display Simple Product SKU, in WooCommerce loop pages, before item name
*
* @return void
*/
function simple_product_sku_before_loop_item_title(){
global $product;
$type = $product->product_type;
@filipecsweb
filipecsweb / same-height.js
Last active October 12, 2016 08:49
Forcing the same height to specific elements
/**
* Define parameters to set 'where' and what 'element' will have same height.
*
* @author Filipe Seabra
* @param where element's father
* @param element selector of the elements that must have same height
*/
jQuery(window).load(function(){
function sameHeight(where, element){
var height = [];
@filipecsweb
filipecsweb / functions.php
Last active April 8, 2019 01:27
Reorder WordPress administration menu items
<?php
/**
* Reorder WordPress administration menu.
*
* en_US pt_BR - Page Name
*
* Appearence (Aparência) = themes.php
* Settings (Configurações) = options-general.php
* Comments (Comentários) = edit-comments.php
* Tools (Ferramentas) = tools.php
@filipecsweb
filipecsweb / functions.php
Last active April 8, 2019 01:53
Change WooCommerce shortcode tag name
<?php
/**
* Change WooCommerce shortcode tag name.
*
* SEE EXISTING TAGS BELOW:
*
* product
* product_page
* product_category
* product_categories
@filipecsweb
filipecsweb / functions.php
Last active April 10, 2019 01:46
Add custom column to shop_order post type
<?php
/**
* Add custom column to shop_order post type
*
* @param $columns array Array of all registered columns.
*
* @return array $new_columns
*/
function add_custom_column_to_shop_order( $columns ) {
$new_columns = is_array( $columns ) ? $columns : array();
@filipecsweb
filipecsweb / functions.php
Last active April 10, 2019 01:49
Add custom value to custom column in shop_order post type
<?php
/**
* Add custom value to custom column in admin on page that lists the shop_order post type.
*
* @param string $column This is the column id/key.
*/
function add_custom_column_value_to_shop_order( $column ) {
global $post;
if ( $column == 'software_key' ) {
@filipecsweb
filipecsweb / functions.php
Created November 6, 2015 02:34
Stop sending "processing order" e-mail when WooCommerce order status changes from pending to on-hold
<?php
/**
* Disable action that sends e-mail to customer, warning that his/her order is processing,
* as this is not true, because when the status changes from pending to on-hold,
* the order is not processing yet.
*
* @return void
*/
function manipulate_woocommerce_email_sending($email_class){
remove_action('woocommerce_order_status_pending_to_on-hold_notification', array($email_class->emails['WC_Email_Customer_Processing_Order'], 'trigger'));
@filipecsweb
filipecsweb / functions.php
Last active May 29, 2019 10:30
Overwrite subject line of the WooCommerce transactional e-mails
<?php
/**
* Sobrescrever assunto dos emails transacionais do WooCommerce.
*
* Tags possíveis para usar como parâmetro em add_filter():
*
* woocommerce_email_subject_new_order = Novo pedido
* woocommerce_email_subject_customer_processing_order = Processando pedido
* woocommerce_email_subject_customer_completed_order = Pedido concluído
* woocommerce_email_subject_customer_invoice = Fatura do cliente
@filipecsweb
filipecsweb / functions.php
Last active November 19, 2019 12:57
Remove order notes from WooCommerce checkout
<?php
add_filter( 'woocommerce_enable_order_notes_field', '__return_false' );