Skip to content

Instantly share code, notes, and snippets.

View monecchi's full-sized avatar

Adriano Monecchi monecchi

View GitHub Profile
@monecchi
monecchi / woocommerce-updated-email-order-items-table.php
Created April 3, 2016 16:07 — forked from bekarice/woocommerce-updated-email-order-items-table.php
WooCommerce Order Emails: Add product images to the order email (WooCommerce 2.5+)
<?php // only copy this line if needed
/**
* Adds product images to the WooCommerce order emails table
* Uses WooCommerce 2.5 or newer
*
* @param string $output the buffered email order items content
* @param \WC_Order $order
* @return $output the updated output
*/
function sww_add_images_woocommerce_emails( $output, $order ) {
@monecchi
monecchi / functions.php
Created April 7, 2016 15:30 — forked from claudiosanches/functions.php
WooCommerce - Change product loop add to cart button
<?php
function custom_woocommerce_loop_add_to_cart_link( $html, $product ) {
return '<a href="' . get_permalink( $product->id ) . '" class="button">' . __( 'Texto do botão' ) . '</a>';
}
add_filter( 'woocommerce_loop_add_to_cart_link', 'custom_woocommerce_loop_add_to_cart_link', 10, 2 );
@monecchi
monecchi / disable-paypal-woocommerce
Created April 16, 2016 01:18 — forked from MindyPostoff/disable-paypal-woocommerce
Disable PayPal in WooCommerce Checkout for Certain Products
/*
* Disable PayPal payment method in the checkout if certain
* products are present in the cart.
*
* Add this to your theme's functions.php file
*/
add_filter( 'woocommerce_available_payment_gateways', 'filter_gateways', 1);
function filter_gateways( $gateways ){
global $woocommerce;
@monecchi
monecchi / gist:c34606ed5dae75c739b0eadc5028a60f
Created April 16, 2016 02:01 — forked from salgua/gist:30ee2bc205d71f758fd9
Woocommerce COD only for specific country with specific shipment rate
//enable COD only for italy
function payment_gateway_disable_country( $available_gateways ) {
global $woocommerce;
if ( isset( $available_gateways['cod'] ) && $woocommerce->customer->get_country() <> 'IT' ) {
unset( $available_gateways['cod'] );
}
//make COD the only available gateway for flat_rate shipping method (or other unused method)
//you can use the label cash on delivery for flat_rate and determining the shipping cost for COD
$chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
// Get The Page ID You Need
get_option( 'woocommerce_shop_page_id' );
get_option( 'woocommerce_cart_page_id' );
get_option( 'woocommerce_checkout_page_id' );
get_option( 'woocommerce_pay_page_id' );
get_option( 'woocommerce_thanks_page_id' );
get_option( 'woocommerce_myaccount_page_id' );
get_option( 'woocommerce_edit_address_page_id' );
get_option( 'woocommerce_view_order_page_id' );
get_option( 'woocommerce_terms_page_id' );
@monecchi
monecchi / gist:56a61a12dbef3d7ce0d6c846c963a550
Created April 18, 2016 06:38 — forked from corsonr/gist:c2781c9e0cc086c5047f
WooCommerce: Add customer username to edit/view order admin page
<?php
// Add WooCommerce customer username to edit/view order admin page
add_action( 'woocommerce_admin_order_data_after_billing_address', 'woo_display_order_username', 10, 1 );
function woo_display_order_username( $order ){
global $post;
$customer_user = get_post_meta( $post->ID, '_customer_user', true );
echo '<p><strong style="display: block;">'.__('Customer Username').':</strong> <a href="user-edit.php?user_id=' . $customer_user . '">' . get_user_meta( $customer_user, 'nickname', true ) . '</a></p>';
@monecchi
monecchi / gist:dd57320a089d00ac667461b34c6fa653
Created April 19, 2016 05:25 — forked from mikejolley/gist:3097073
WooCommerce - Unhook/Disable emails
/**
* Code goes in functions.php or a custom plugin.
*/
add_action( 'woocommerce_email', 'unhook_those_pesky_emails' );
function unhook_those_pesky_emails( $email_class ) {
/**
* Hooks for sending emails during store events
**/
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! class_exists( 'WC_Process_Order_Email' ) ) :
/**
* Factory Completed Order Email
*
* An email sent to the factory when a new order is completed.
*
@monecchi
monecchi / gist:b6cec3d09d0ac8562be39d95fd7f50b6
Created April 19, 2016 06:18 — forked from mikejolley/gist:1926284
WooCommerce - Change WooCommerce email subject lines
/*
* goes in theme functions.php or a custom plugin
*
* Subject filters:
* woocommerce_email_subject_new_order
* woocommerce_email_subject_customer_processing_order
* woocommerce_email_subject_customer_completed_order
* woocommerce_email_subject_customer_invoice
* woocommerce_email_subject_customer_note
* woocommerce_email_subject_low_stock
@monecchi
monecchi / functions.php
Created April 19, 2016 06:19 — forked from kloon/functions.php
WooCommerce add payment type to emails
<?php
// Place the following code in your theme's functions.php file to add the payment type to all emails
add_action( 'woocommerce_email_after_order_table', 'wc_add_payment_type_to_emails', 15, 2 );
function wc_add_payment_type_to_emails( $order, $is_admin_email ) {
echo '<p><strong>Payment Type:</strong> ' . $order->payment_method_title . '</p>';
}
// Place the following code in your theme's functions.php file to add the payment type to admin emails only
add_action( 'woocommerce_email_after_order_table', 'wc_add_payment_type_to_admin_emails', 15, 2 );
function wc_add_payment_type_to_admin_emails( $order, $is_admin_email ) {