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 to custom URL based on their role after login and restore the cart | |
* | |
* @param string $redirect | |
* @param object $user | |
* @return string | |
*/ | |
function wp_custom_user_redirect( $redirect, $user ) { | |
// Get the first of all the roles assigned to the user |
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
if ( ! function_exists( 'is_woocommerce_activated' ) ) { | |
function is_woocommerce_activated() { | |
if ( class_exists( 'woocommerce' ) ) { return true; } else { 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
// Ensure cart contents update when products are added to the cart via AJAX (place the following in functions.php). | |
// Used in conjunction with https://gist.github.com/DanielSantoro/1d0dc206e242239624eb71b2636ab148 | |
add_filter('add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment'); | |
function woocommerce_header_add_to_cart_fragment( $fragments ) { | |
global $woocommerce; | |
ob_start(); | |
?> |
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
<input type="text" name="attachments[123][field_name]" /> |
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
/* | |
This code will redirect users from the default PMPro confirmation page to a specific page depending on their level. | |
Set the confirmation_pages array. Array keys should be membership level ids and the values are the page ids. So array(1=>2) will redirect membership level with id = 1 to the page with id = 2. | |
*/ | |
function my_pmpro_confirmation_redirect() | |
{ | |
$confirmation_pages = array(1 => 2); //change this use your membership level ids and page ids | |
global $pmpro_pages; | |
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 | |
function email_past_due() { | |
global $wpdb; | |
$mailer = WC_Emails::instance(); | |
$date = date( "Y-m-d H:i:s", current_time( 'timestamp' ) + 86400 * 7 ); | |
$due_orders = $wpdb->get_col( $wpdb->prepare( " | |
SELECT posts.ID | |
FROM {$wpdb->posts} AS posts |
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 lgbk_add_member( $order_id ) { | |
$order = new WC_Order( $order_id ); | |
$items = $order->get_items(); | |
foreach ( $items as $item ) { | |
$product_name = $item['name']; | |
$product_id = $item['product_id']; | |
$product_variation_id = $item['variation_id']; | |
} |
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 wcs_redirect_product_based ( $order_id ){ | |
$order = wc_get_order( $order_id ); | |
foreach( $order->get_items() as $item ) { | |
$_product = wc_get_product( $item['product_id'] ); | |
// Add whatever product id you want below here | |
if ( $item['product_id'] == 70 ) { | |
// change below to the URL that you want to send your customer to | |
wp_redirect('http://www.yoururl.com/your-thank-you-page'); | |
} |
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 | |
// Display variations dropdowns on shop page for variable products | |
add_filter( 'woocommerce_loop_add_to_cart_link', 'woo_display_variation_dropdown_on_shop_page' ); | |
function woo_display_variation_dropdown_on_shop_page() { | |
global $product; | |
if( $product->is_type( 'variable' )) { | |
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
// Get The Page ID You Need | |
get_option( 'woocommerce_shop_page_id' ); | |
get_option( 'woocommerce_cart_page_id' ); | |
get_option( 'woocommerce_checkout_page_id' ); | |
get_option( 'woocommerce_pay_page_id' ); | |
get_option( 'woocommerce_thanks_page_id' ); | |
get_option( 'woocommerce_myaccount_page_id' ); | |
get_option( 'woocommerce_edit_address_page_id' ); | |
get_option( 'woocommerce_view_order_page_id' ); | |
get_option( 'woocommerce_terms_page_id' ); |
OlderNewer