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 | |
/** | |
* Redirect users after add to cart. | |
*/ | |
function my_custom_add_to_cart_redirect( $url ) { | |
if ( ! isset( $_REQUEST['add-to-cart'] ) || ! is_numeric( $_REQUEST['add-to-cart'] ) ) { | |
return $url; | |
} | |
$product_id = apply_filters( 'woocommerce_add_to_cart_product_id', absint( $_REQUEST['add-to-cart'] ) ); | |
// Only redirect products with the 'small-item' shipping class |
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 | |
/** | |
* Redirect users after add to cart. | |
*/ | |
function my_custom_add_to_cart_redirect( $url ) { | |
if ( ! isset( $_REQUEST['add-to-cart'] ) || ! is_numeric( $_REQUEST['add-to-cart'] ) ) { | |
return $url; | |
} | |
$product_id = apply_filters( 'woocommerce_add_to_cart_product_id', absint( $_REQUEST['add-to-cart'] ) ); | |
// Only redirect products that have the 't-shirts' category |
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 | |
/** | |
* Redirect users after add to cart. | |
*/ | |
function my_custom_add_to_cart_redirect( $url ) { | |
$url = WC()->cart->get_checkout_url(); | |
// $url = wc_get_checkout_url(); // since WC 2.5.0 | |
return $url; | |
} | |
add_filter( 'woocommerce_add_to_cart_redirect', 'my_custom_add_to_cart_redirect' ); |
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 | |
/** | |
* Redirect users after add to cart. | |
*/ | |
function my_custom_add_to_cart_redirect( $url ) { | |
$url = get_permalink( 1 ); // URL to redirect to (1 is the page ID here) | |
return $url; | |
} | |
add_filter( 'woocommerce_add_to_cart_redirect', 'my_custom_add_to_cart_redirect' ); |
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 | |
/** | |
* Redirect users after add to cart. | |
*/ | |
function my_custom_add_to_cart_redirect( $url ) { | |
if ( ! isset( $_REQUEST['add-to-cart'] ) || ! is_numeric( $_REQUEST['add-to-cart'] ) ) { | |
return $url; | |
} | |
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
function reverseString(str) { | |
return str.split('').reverse().join(''); | |
} | |
reverseString("hello", ""); |
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
function factorialize(num) { | |
result = 1; | |
for (var i = 1; i <= num; i++) { | |
result *= i; | |
} | |
return result; | |
} | |
factorialize(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
function palindrome(str) { | |
str = str.replace(/\s/gi, ''); // replace empty spaces | |
str = str.replace(/\W/gi, ''); // replaces non-word characters | |
str = str.replace(/_/, ''); // replaces underscore symbol | |
str = str.toLowerCase(); // lowercases the string | |
var strReversed = str.split('').reverse().join(''); //reversed the string | |
return (str === strReversed) ? true : false; // returns false if the str =! strReversed | |
} |
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
function findLongestWord(str) { | |
var myArray = str.split(' '); | |
var arrayData = myArray[0].length; | |
for (var i = 0; i < myArray.length; i++) { | |
if (arrayData < myArray[i].length) { | |
arrayData = myArray[i].length; | |
} | |
} | |
return arrayData; |
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
function titleCase(str) { | |
str = str.toLowerCase(); | |
var split = str.split(' '); | |
for (var i = 0; i < split.length; i++) { | |
split[i] = split[i].charAt(0).toUpperCase() + split[i].slice(1); | |
} | |
var capitalizeString = split.join(' '); | |
return capitalizeString; |
NewerOlder