This file contains hidden or 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 | |
add_action( 'woocommerce_email_before_order_table', 'add_content', 20, 4 ); | |
function add_content($order, $sent_to_admin, $plain_text, $email) { | |
// Adds to "completed order" email only | |
if ( $email->id == 'customer_completed_order' ) { | |
// set initial variables to false | |
$both = false; |
This file contains hidden or 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 | |
// create a function that returns the path of the product import CSV with today's date at the end of the filename | |
function fs_import_gen_url() { | |
return "https://www.example.com/csv/your-product-import-" . date("Y_m_d") . ".csv"; | |
// e.g., YYYY_MM_DD = 2019_03_23 | |
} | |
// then add this shortcode as the URL for the WP All Import file: [fs_import_gen_url()] |
This file contains hidden or 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 | |
// Send an email containing the import results after the import has finished | |
function fs_email_results( $import_id ) { | |
global $wpdb; | |
$table = $wpdb->prefix . 'pmxi_imports'; | |
$data = $wpdb->get_row( 'SELECT * FROM `' . $table . '` WHERE `ID` = "' . $import_id . '"' ); | |
if ( $data ) { | |
$msg = "Import Report for Import ID " . $import_id . "\r\n\r\n"; | |
$msg .= "Created: " . $data->created . "\r\n"; | |
$msg .= "Updated: " . $data->updated . "\r\n"; |
This file contains hidden or 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 | |
$string = "Take 50.5% OFF"; | |
if (preg_match("/[\d.]+(?=%)/", $string, $matches)) { | |
$percentage = $matches[0]; | |
echo $percentage; | |
} | |
?> |
This file contains hidden or 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 | |
// https://developer.wordpress.org/reference/hooks/wp_new_user_notification_email/ | |
add_filter( 'wp_new_user_notification_email', 'custom_wp_new_user_notification_email', 10, 3 ); | |
function custom_wp_new_user_notification_email( $wp_new_user_notification_email, $user, $blogname ) { | |
$wp_new_user_notification_email['subject'] = sprintf( 'Acme Co Web Portal Log In', $blogname, $user->user_login ); | |
$message = __( 'You are receiving this email and log in information because you have active project/projects with Acme Co. If you would like, you can check the status of your project/projects by logging into the client portal and clicking on "My Projects". After you log in, "My Projects" is on the left hand side just below the "Dashboard" button.' ) . "\r\n\r\n"; | |
$message .= __( 'Also available in the client portal is the following:' ) . "\r\n\r\n"; | |
$message .= __( 'You can upload files to a team leader' ) . "\r\n"; |
This file contains hidden or 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 | |
// Check if product is set to New = Yes and/or Featured = Yes | |
// then, display the Featured or New product attribute terms if = Yes | |
add_shortcode( 'fs-product-featured-new', 'fs_product_featured_new_shortcode' ); | |
function fs_product_featured_new_shortcode( $atts ) { | |
// begin output buffering | |
ob_start(); | |
// grab the terms of the product's attributes | |
$new_terms = get_the_terms($post->ID, 'pa_new'); |
This file contains hidden or 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 | |
// Creates a block/card for each product (including variations) with Price, Stock, Size, etc. under each single product display | |
// https://stackoverflow.com/a/49565625/1887218 | |
// Utility funtion: getting and formtting product data | |
function format_product_data_output( $the_id ){ | |
$empty = __( '<em>(empty)</em>', 'woocommerce' ); | |
// Get an instance of the WC_Product_Variation object |
This file contains hidden or 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 | |
// resize only for non-admin | |
add_filter( 'wp_smush_resize_uploaded_image', 'smush_resize_non_admin', 10, 3 ); | |
function smush_resize_non_admin($should_resize, $id, $meta) { | |
global $current_user; | |
if ( current_user_can('manage_options') ) { | |
return false; | |
} |
This file contains hidden or 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 | |
/** | |
* Change "Featured" category name on the frontend | |
* if on the product page of Featured, then change the "Featured" text to be custom text instead | |
**/ | |
function change_woocommerce_category_page_title( $page_title ) { | |
if ( ( is_product_category() ) && ( 'Featured' == $page_title ) ) { | |
$page_title = "Your Custom Category Title Here"; | |
} | |
return $page_title; |
This file contains hidden or 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 | |
/************** | |
DIFFERENT MESSAGES FOR DIFFERENT PRODUCTS | |
****************/ | |
//hook our function to the new order email | |
add_action('woocommerce_email_order_details', 'email_order_details_products', 1, 4); | |
function email_order_details_products($order, $admin, $plain, $email) { |