Skip to content

Instantly share code, notes, and snippets.

View CrispDev's full-sized avatar

Crisp Design Custom Dev CrispDev

  • Crisp Design Co. Custom Project Development
  • Denver, CO
View GitHub Profile
@CrispDev
CrispDev / functions.php
Created February 11, 2019 21:19
Autoship Customization // Change Link in My Account > Addresses Screen for Update Scheduled Orders option
/**
* Customize Link on Addresses Page
* @param string $html The current link html.
* @param string $link The link to update the scheduled orders.
* @return string The updated html for the link.
*/
function xx_customize_update_my_autoship_scheduled_orders_link( $html, $link ){
return sprintf( __('<p style="padding:10px;border:1px solid #eee;border-radius:5px">Click <a href="%s">here</a> to update you shipping address on all Scheduled Orders</p>', 'autoship'), $link );
}
add_filter( 'autoship_display_apply_customer_info_to_all_scheduled_orders_btn_link_label', 'xx_customize_update_my_autoship_scheduled_orders_link', 10, 2);
@CrispDev
CrispDev / functions.php
Last active April 16, 2019 13:11
Autoship Customization // Remove Non-Autoship Supported Gateways when Cart includes 1+ Autoship items
/**
* Custom Added by Autoship Cloud Custom Development
* Filter for only Valid Autoship Payment Gateways
* @param array $gateways The array of available payment gateways.
* @return array The filtered $gateways
*/
function xx_filter_autoship_gateways( $gateways ){
// if Autoship is not installed return all gateways.
@CrispDev
CrispDev / functions.php
Created February 14, 2019 22:47
Autoship Customization // Modify Health Check Duration
/**
* Adjust the duration between health checks
* NOTE Health checks only occur when logged in as an admin and only when looking at the admin menu.
*
* @param int $duration The delay between health checks
* @return int The filtered duration
*/
function xx_filter_autoship_healthcheck_duration( $duration ){
return 240;
@CrispDev
CrispDev / functions.php
Created February 15, 2019 18:21
Autoship Customization // Remove Session Actions
/**
* The following three hooks remove the session actions used in the autoship native ui.
* Note when not using the Session variable the Native UI option should not be used for Schedule Orders.
*/
function xx_remove_autoship_session_init_hooks(){
remove_action( 'init', 'autoship_start_session', 1);
}
add_action( 'init', 'xx_remove_autoship_session_init_hooks', 0 );
function xx_remove_autoship_session_logout_hooks(){
@CrispDev
CrispDev / functions.php
Last active March 14, 2019 15:19
Autoship Customization // Remove Chatbot Script & Style Sheet
/**
* Dequeue the Chatbot script.
*
* Hooked to the wp_print_scripts action, with a late priority (100),
* so that it is after the script was enqueued.
*/
function xx_dequeue_script() {
wp_dequeue_script( 'autoship-webchat' );
}
add_action( 'wp_print_scripts', 'xx_dequeue_script', 100 );
@CrispDev
CrispDev / functions.php
Created March 5, 2019 06:11
Autoship Customization // Change the Autoship Label On Product and Product Variations
/**
* Filter the Autoship Label
*
* @param string $autoship_select Yes or No for autoship or not.
* @param bool $discount True if there is a discount else false.
* @param WC_Product $product The wc product object.
* @return string The filtered label.
*/
function xx_adjust_autoship_label( $label, $autoship_select, $discount, $product ){
@CrispDev
CrispDev / functions.php
Created March 13, 2019 18:53
Autoship Customization // Adjust Security rights to Autoship Cloud Menu and Submenu Admin Pages
/**
* Adjusts the Security for the Autoship Sub Pages
* @link https://codex.wordpress.org/Roles_and_Capabilities#Capability_vs._Role_Table
*
* @param string $capability The current required cap.
* @param string $menu_slug The Sub Menu Page.
* @return string $capability The filtered cap.
*/
function xx_adjust_autoship_cloud_subpage_security( $capability, $menu_slug ){
@CrispDev
CrispDev / functions.php
Last active March 14, 2019 17:00
Autoship Customization // Change Autoship Labels on Product Pages and Cart
/**
* Change Product Page and Cart Autoship labels
*
* @param string $label The current option label.
* @param string $option_type if this is the autoship radio or 'no' if this is the one time purchase
* @param bool $savings if there is a savings associated with autoship else false.
* @param WC_Product $product The current product object.
*
* @return string the filtered label
*/
@CrispDev
CrispDev / AutoshipUseSnippet.php
Created March 21, 2019 19:44
Autoship Usage Snippet // Update The Shipping Address for a Customer on All Scheduled Orders
/**
* Updates the Shipping Address on all scheduled orders for the supplied user
* using the Address currintly in My Account > Addresses > Shipping Address
*
* @param $wc_user_id The WC Customer ID.
*/
function xx_update_all_scheduled_orders_with_current_shipping( $wc_user_id ){
// Using the Built in Autoship Function which
// a) Connects to QPilot API
@CrispDev
CrispDev / functions.php
Created March 26, 2019 16:59
Autoship Customization // Change Autoship Schedule: label on Order and Cart Metadata
/**
* Updates the Schedule metadata label
* Ex. Schedule: Every 1 Months => Re-Order Schedule: Every 1 Months
* @param string $label the current label.
* @return string $label The filtered label.
*/
function xx_update_all_schedule_labels( $label ){
return 'Re-Order Schedule';