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
jQuery( function($) { | |
/* ------------------------------------------------------------------------------------ */ | |
/* Document Ready */ | |
/* ------------------------------------------------------------------------------------ */ | |
$(document).ready( function() { | |
// Attach the Ajax class to the add-to-cart button | |
$(".single_add_to_cart_button").addClass("ajax_add_to_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
<?php | |
/** | |
* Applies a custom checkout price to a speicific priduct with a frequency type and number | |
* otherwise returns original checkout price. | |
* @param float $checkout_price. The current discounted or not checkout price for this autoship product. | |
* @param int $product_id. The current product's id. | |
* @param string $frequency_type. The Autoship frequency type ( Months, Days, etc ). | |
* @param int $frequency. The frequency value. | |
* | |
* @return float The new calculated checkout price or the originally supplied |
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 | |
add_filter('autoship_simple_product_discount_price_html_selector' , 'customize_autoship_simple_product_price_selector', 10, 1 ); | |
function customize_autoship_simple_product_price_selector( $selector ){ | |
return '.entry-summary__inventory > .woocommerce-Price-amount'; | |
} | |
add_filter('autoship_simple_product_discount_price_html', 'customize_autoship_simple_product_price_html', 10 , 3 ); | |
function customize_autoship_simple_product_price_html( $discounted_price_html, $autoshipCheckoutPrice, $product ){ | |
$autoshipNormalPrice = $product->get_price(); |
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 autoship_new_default_frequency_options( $options ) { | |
// Return a new set of default frequency options of 1 through 4 Weeks | |
return array( | |
array( | |
// Days, Weeks, Months, DayOfTheWeek, DayOfTheMonth | |
'frequency_type' => 'Weeks', | |
// Frequency (integer) | |
'frequency' => 2, | |
'display_name' => 'Every 2 Weeks' | |
), |
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
// Default the Autoship option for both Simple and | |
// Variable products by default. | |
function xx_default_autoship_for_all( $default ){ | |
return 'yes'; | |
} | |
add_filter('autoship_default_product_schedule_options_choice_value', 'xx_default_autoship_for_all', 10 ,1); |
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
// Adjust Scheduled Order Checkout Price. | |
function xx_adjust_checkout_price( $checkout_price, $product_id, $frequency_type, $frequency ){ | |
// Adjust the checkout price based on the frequency and type | |
if ( ( 'Days' == $frequency_type ) && ( 1 == $frequency ) ){ | |
$discount_pct = .5; | |
} else if ( ( 'Weeks' == $frequency_type ) && ( 1 == $frequency ) ){ |
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
jQuery(function ($) { | |
/** | |
* Displays a custom discounted price based on | |
* Selected Autoship frequency & type. | |
*/ | |
function xx_custom_autoship_schedule_options_price($) { | |
// Add the discount data per frequency and type as a variable loaded into the page. | |
var option_price_discount_lookup = { |
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 increase_required_cart_qty( $count ){ | |
return $count >= 3; | |
} | |
function autoship_adjust_coupon_is_valid( $valid, $coupon ) { | |
add_filter( 'autoship_valid_cart_total_min_required','increase_required_cart_qty', 10, 1); | |
$valid = autoship_cart_has_valid_autoship_items(); | |
remove_filter( 'autoship_valid_cart_total_min_required','increase_required_cart_qty'); | |
return $valid; |
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
/** | |
* Filter the Status names displayed in the Native Scheduled Order dashboard and order detail page. | |
* @param array $statuses The current status and it's display name. | |
* @return array | |
*/ | |
function xx_adjust_autoship_status_nicenames( $statuses ){ | |
// Optionally use autoship_rights_checker() to determine which version of nicenames to display | |
return array ( | |
'Active' => 'Scheduled', |
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
/** | |
* Force all the users autoship orders to be updated if the user | |
* Changes their address info. | |
* | |
* @param bool $update The current update flag. True updates all orders, false doesn't | |
* @param int $user_id The current users id. | |
* | |
* @return bool The filtered update flag. | |
*/ |
OlderNewer