Skip to content

Instantly share code, notes, and snippets.

View manlioma's full-sized avatar

ManlioMa manlioma

View GitHub Profile
@manlioma
manlioma / wc-condtionally-add-email-recipient.php
Created August 17, 2017 10:38
Add WooCommerce "New Order" email recipient if a product in the order needs shipping Raw
<?php
/**
* Add another email recipient for admin New Order emails if a shippable product is ordered
*
* @param string $recipient a comma-separated string of email recipients (will turn into an array after this filter!)
* @param \WC_Order $order the order object for which the email is sent
* @return string $recipient the updated list of email recipients
*/
function sv_conditional_email_recipient( $recipient, $order ) {
// Bail on WC settings pages since the order object isn't yet set yet
@manlioma
manlioma / woocommerce_email_recipient_customer_invoice.php
Last active August 17, 2017 10:33
additional recipients to a WooCommerce email order type, based on the order email address
// This sample code will add additional recipients to a WooCommerce email order type, based on the order email address
// Email id's for the various email types (i.e. customer_invoice) can be found here:
// https://github.com/woothemes/woocommerce/blob/5e09f15c91970d8bec4ab56abbfd5d3039a02a1b/includes/emails/class-wc-email-customer-invoice.php#L30https://github.com/woothemes/woocommerce/blob/5e09f15c91970d8bec4ab56abbfd5d3039a02a1b/includes/emails/class-wc-email-customer-invoice.php#L30
// Add the following to the bottom of your theme's functions.php:
add_filter( 'woocommerce_email_recipient_customer_invoice', 'woocommerce_email_customer_invoice_add_recipients' );
function woocommerce_email_customer_invoice_add_recipients( $recipient, $order ) {
if ( '[email protected]' == $recipient ) {
$recipient .= ', [email protected]';
/* ucc_get_calendar() :: Extends get_calendar() by including custom post types.
* Derived from get_calendar() code in /wp-includes/general-template.php.
*/
function ucc_get_calendar( $post_types = '' , $initial = true , $echo = true ) {
global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
if ( empty( $post_types ) || !is_array( $post_types ) ) {
$args = array(
'public' => true ,
@manlioma
manlioma / sensei_course_complete.php
Created January 12, 2017 23:33
Funzione Per Sensei Corso COmpletato da Lezione
// Controllo se l'utente ha completato il corso
$course_id = intval( get_post_meta( $post->ID, '_lesson_course', true ) ); // Id del corso di cui fa parte la lezione
$user_id = get_current_user_id(); // Id Utente
// Check if course is completed
$user_course_status = Sensei_Utils::user_course_status( $course_id, $user_id );
$completed_course = Sensei_Utils::user_completed_course( $user_course_status );
// Success message
if ( $completed_course ) { ?>
@manlioma
manlioma / add_check_box_to_checkout.php
Last active August 17, 2017 10:35
WC - Add checkbox field to the checkout
/**
* Add checkbox field to the checkout: INFORMATIVA PRIVACY
**/
add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');
function my_custom_checkout_field( $checkout ) {
$home = home_url( '/' );