This file contains 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
add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' ); | |
add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' ); | |
function wc_minimum_order_amount() { | |
// Set this variable to specify a minimum order value | |
$minimum = 50; | |
if ( WC()->cart->total < $minimum ) { | |
if( is_cart() ) { |
This file contains 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
/** | |
* Allows to duplicate products with the capability edit_products | |
*/ | |
add_filter( 'woocommerce_duplicate_product_capability', create_function( '', 'return "edit_products";' ) ); |
This file contains 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
/** | |
* Hides checkout fields based on the products in the cart | |
* | |
* @param array $fields | |
* @return array | |
*/ | |
function conditional_checkout_fields_products( $fields ) { | |
$cart = WC()->cart->get_cart(); | |
foreach ( $cart as $item_key => $values ) { |
This file contains 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
/** | |
* Does not filter related products by tag | |
*/ | |
add_filter( 'woocommerce_product_related_posts_relate_by_tag', '__return_false' ); | |
/** | |
* Does not filter related products by category | |
*/ | |
add_filter( 'woocommerce_product_related_posts_relate_by_category', '__return_false' ); |
This file contains 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
<? | |
//CSP only works in modern browsers Chrome 25+, Firefox 23+, Safari 7+ | |
$headerCSP = "Content-Security-Policy:". | |
"connect-src 'self' ;". // XMLHttpRequest (AJAX request), WebSocket or EventSource. | |
"default-src 'self';". // Default policy for loading html elements | |
"frame-ancestors 'self' ;". //allow parent framing - this one blocks click jacking and ui redress | |
"frame-src 'none';". // vaid sources for frames | |
"media-src 'self' *.example.com;". // vaid sources for media (audio and video html tags src) | |
"object-src 'none'; ". // valid object embed and applet tags src | |
"report-uri https://example.com/violationReportForCSP.php;". //A URL that will get raw json data in post that lets you know what was violated and blocked |
This file contains 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
define(function () { | |
'use strict'; | |
var canvas = document.createElement('canvas'); | |
var ctx = canvas.getContext('2d'); | |
return function ($srcImg) { | |
var deferred = $.Deferred(); | |
var srcImg = $srcImg[0]; |
This file contains 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
require('font-awesome/css/font-awesome.css'); | |
document.body.innerHTML = '<i class="fa fa-fw fa-question"></i>'; |
This file contains 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
add_action( 'wc_custom_thankyou_failed', 'wc_custom_thankyou_failed', 10 ); | |
function wc_custom_thankyou_failed( $order ) { | |
wc_get_template( 'custom-thankyou/failed.php', array( 'order' => $order ) ); | |
} | |
add_action( 'wc_custom_thankyou_successful', 'wc_custom_thankyou_header', 10 ); | |
function wc_custom_thankyou_header( $order ) { | |
wc_get_template( 'custom-thankyou/header.php', array( 'order' => $order ) ); | |
} |
This file contains 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 | |
/* get the terms for the taxonomy */ | |
$terms = get_terms( | |
'taxonomy_name_here', | |
array( | |
'hide_empty' => false | |
) | |
); |
This file contains 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
<header> | |
<h2><?php _e( 'Customer details', 'woocommerce' ); ?></h2> | |
</header> | |
<dl class="customer_details"> | |
<?php | |
if ( $order->billing_email ) echo '<dt>' . __( 'Email:', 'woocommerce' ) . '</dt><dd>' . $order->billing_email . '</dd>'; | |
if ( $order->billing_phone ) echo '<dt>' . __( 'Telephone:', 'woocommerce' ) . '</dt><dd>' . $order->billing_phone . '</dd>'; | |
// Additional customer details hook | |
do_action( 'woocommerce_order_details_after_customer_details', $order ); |