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
# Spend $A, get B% off, spend $C get D% off, spend $E get F% off | |
# Custom Message | |
CHECKOUT_MESSAGE = "Special discount" | |
# Discount rules | |
# ORDER MINIMUM IN DOLLARS => DISCOUNT VALUE (%) | |
DISCOUNT_RULES = { | |
50 => 5, | |
100 => 10, |
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 | |
// Just add the following code to boot() method: | |
// \URL::forceSchema('https'); // for Laravel 5.3 | |
// \URL::forceScheme('https'); // for Laravel 5.4 | |
// ... | |
class AppServiceProvider extends ServiceProvider | |
{ |
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
# Restart PHP-FPM on CloudWays via API | |
# Replace YOUR_NAME%40DOMAIN.COM with your email (URL-encoded), YOUR_API_KEY with your Cloudways API key and SERVER_ID with id of your server | |
# If you want to use it with DeployBot just add the following commands to the "Run commands after new version becomes active" section. | |
# Do auth and receive access_token | |
cloudways_token=$(curl -X POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' -d 'email=YOUR_NAME%40DOMAIN.COM&api_key=YOUR_API_KEY' 'https://api.cloudways.com/api/v1/oauth/access_token' | python3 -c "import sys, json; print(json.load(sys.stdin)['access_token'])") | |
# Restart PHP-FPM | |
curl -X POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' --header "Authorization: Bearer ${cloudways_token}" -d 'server_id=SERVER_ID&service=php7.0-fpm&state=restart' 'https://api.cloudways.com/api/v1/service/state' |
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
$('.element').on('mouseup', function(event){ | |
var selection; | |
if (window.getSelection) { | |
selection = window.getSelection(); | |
} else if (document.selection) { | |
selection = document.selection.createRange(); | |
} | |
selection.toString() !== '' && alert('"' + selection.toString() + '" was selected at ' + event.pageX + '/' + event.pageY); |
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 | |
// Hide WooCommerce product price, attributes and variations for non-logged-in users | |
function my_theme_hide_price_not_authorized() { | |
if ( !is_user_logged_in() ) { | |
// Hide price | |
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 ); | |
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); | |
// Hide variations | |
add_filter( 'woocommerce_variation_is_active', 'my_theme_disable_variation', 10, 2 ); | |
// Hide Add-to-cart button |
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 | |
// Change available package rates depending on cart total | |
function shipping_method_on_cart_total( $rates, $package ) { | |
$cart_total = WC()->cart->total; | |
$condition_price = 1000.00; | |
if( $cart_total > $condition_price ) { | |
unset( $rates['free_shipping'] ); // Remove free shipping | |
} | |
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 | |
// Change available payment methods depending on cart total | |
function payment_gateway_disable_payment_method( $available_gateways ) { | |
$cart_total = WC()->cart->total; | |
$condition_price = 1000.00; | |
if ( isset($available_gateways['cod']) && ($cart_total > $condition_price) ) { | |
unset( $available_gateways['cod'] ); // Disable "Cash on Delivery" payment method | |
} | |
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
*[id]:before { | |
display: block; | |
content: " "; | |
margin-top: -75px; | |
height: 75px; | |
visibility: hidden; | |
} |
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
// Invoice markup | |
// Author: Max Kostinevich | |
// BETA (no styles) | |
// http://pdfmake.org/playground.html | |
// playground requires you to assign document definition to a variable called dd | |
// CodeSandbox Example: https://codesandbox.io/s/pdfmake-invoice-oj81y | |
var dd = { |
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 | |
# Load WordPress barebones | |
define( 'WP_USE_THEMES', false ); | |
require( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' ); | |
# Multisite domain | |
$main_site = 'example.com'; | |
# Type of Multisite | |
$subdomain_install = false; |