Skip to content

Instantly share code, notes, and snippets.

@damiencarbery
damiencarbery / wc-disable-product-link-in-order-page.php
Last active December 2, 2021 10:10
WooCommerce disable product link in Order page - Disable link to product in WooCommerce Order page (in My Account area). https://www.damiencarbery.com/2021/05/disable-product-link-in-woocommerce-order-page/
@damiencarbery
damiencarbery / attach-order-files-to-wc-order-email.php
Last active September 15, 2023 08:44
Attach files to WooCommerce order email - Upload files to an order to attach them to the WooCommerce Order Completed email.
<?php
/*
Plugin Name: Attach files to WooCommerce order email
Plugin URI: https://www.damiencarbery.com/2021/05/attach-files-to-woocommerce-order-email/
Description: Upload files to an order to attach them to the WooCommerce Order Completed email.
Author: Damien Carbery
Author URI: https://www.damiencarbery.com
Version: 0.7
WC tested to: 8.1.0
*/
@dartrax
dartrax / functions.php
Last active September 29, 2022 19:14
Translate WooCommerce and WooCommerce Germanized mails into order language with TranslatePress before sending. Note: As of TranslatePress Version 2.3.5, this functionality was implemented natively by TranslatePress, making this Code obsolete. Read more here: https://translatepress.com/docs/translating-woocommerce-emails/
// Save the current language in post_meta when checkout is processed (used to identify correct Email language)
add_action('woocommerce_checkout_update_order_meta', 'dartrax_save_language_on_checkout', 10, 2 );
function dartrax_save_language_on_checkout( $order_id, $posted ) {
if( ! class_exists('TRP_Translate_Press') ) return '';
global $TRP_LANGUAGE;
update_post_meta( $order_id, 'order_language', $TRP_LANGUAGE );
}
// Woocommerce Germanized Mails
add_action( 'woocommerce_gzd_shipment_status_draft_to_shipped_notification', 'dartrax_prepare_locale_for_Mail_with_shipment_id', 5, 1 );
@dartrax
dartrax / functions.php
Last active February 26, 2024 12:18
Translate WooCommerce mails into order language with TranslatePress before sending. Note: As of TranslatePress Version 2.3.5, this functionality was implemented natively by TranslatePress, making this Code obsolete. Read more here: https://translatepress.com/docs/translating-woocommerce-emails/
// Save the current language in post_meta when checkout is processed (used to identify correct Email language)
add_action('woocommerce_checkout_update_order_meta', 'dartrax_save_language_on_checkout', 10, 2 );
function dartrax_save_language_on_checkout( $order_id, $posted ) {
if( ! class_exists('TRP_Translate_Press') ) return '';
global $TRP_LANGUAGE;
update_post_meta( $order_id, 'order_language', $TRP_LANGUAGE );
}
// Woocommerce Shipment Mails
add_action( 'woocommerce_order_status_processing_to_cancelled_notification','dartrax_prepare_locale_for_Mail_with_order_id', 5, 1 );
@damiencarbery
damiencarbery / email-order-details.php
Last active June 14, 2023 17:00
Add column to WooCommerce order email - Add an extra column to the WooCommerce order email. https://www.damiencarbery.com/2020/10/add-column-to-woocommerce-order-email/
<?php
/**
* Order details table shown in emails.
*
* This template can be overridden by copying it to yourtheme/woocommerce/emails/email-order-details.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
@damiencarbery
damiencarbery / add-manage-options-to-user.php
Created June 15, 2020 17:33
Add capability to a specific user - Add 'manage_options' capability to an non-admin user. https://www.damiencarbery.com/2020/06/add-capability-to-a-specific-user/
<?php
/*
Plugin Name: Add capability to a specific user
Plugin URI: https://www.damiencarbery.com/2020/06/add-capability-to-a-specific-user/
Description: Add 'manage_options' capability to an non-admin user.
Author: Damien Carbery
Author URI: https://www.damiencarbery.com
Version: 0.1
*/
@TaylorBeeston
TaylorBeeston / photoOptimizer.js
Last active July 11, 2022 20:39
Optimize photos client-side
const MAX_WIDTH = process.env.PHOTO_MAX_WIDTH || 800;
const QUALITY = process.env.PHOTO_QUALITY || 0.9;
const readPhoto = async (photo) => {
const canvas = document.createElement('canvas');
const img = document.createElement('img');
// create img element from File object
img.src = await new Promise((resolve) => {
const reader = new FileReader();
@damiencarbery
damiencarbery / remove-add-to-cart-conditionally.php
Last active February 4, 2022 11:48
Remove 'Add to cart' conditionally - Conditionally remove the 'Add to cart' button in WooCommerce. https://www.damiencarbery.com/2020/03/remove-add-to-cart-conditionally/
<?php
/*
Plugin Name: Remove 'Add to cart' conditionally
Plugin URI: https://www.damiencarbery.com/2020/03/remove-add-to-cart-button-conditionally/
Description: Conditionally remove the 'Add to cart' button in WooCommerce.
Author: Damien Carbery
Version: 0.4
WC tested up to: 5.1.0
*/
@signalpoint
signalpoint / README.md
Last active July 9, 2023 01:53
Bootstrap 4 Dynamic Modal with JavaScript

Use this to dynamically create and set the content of a Bootstrap 4 Modal.

In this example, we chose an onclick handler to initialize the modal (only once), and then set the content of the modal dynamically.

@rupesx26
rupesx26 / config.js
Last active February 27, 2020 18:36
How to use multiple spin loader in page
//Hope you added spin.js and spin.css added in your html folder
// Custom spinner config
const customSpinner = {
custSpinUno: {
scale: 0.18,
color: '#d0d5db'
},
custSpinDos: {
scale: 0.18,