Products: Add Autoship Options to Custom Theme Product Templates
(src/cart.php) Add Autoship options to simple and variable product templates in a custom theme.
Important: Always test customizations to your site on a staging environment before making changes to your live / production site. If you are not experienced with testing changes on a staging site, here is a good article to review.
Example:
/** * Autoship Cloud currently integrates with the WooCommerce Shop templates as follows: * 1. Simple Products - The "woocommerce_before_add_to_cart_button" action is used. * - found in woocommerce/templates/single-product/add-to-cart/simple.php * 2. Variation Products - The "woocommerce_before_single_variation" action is used. * - found in woocommerce/templates/single-product/add-to-cart/variable.php * * IMPORTANT! If your theme uses custom templates replacing either of these files and * does not include the WooCommerce hooks you will need to add custom actions * in equivalent locations as the WooCommerce actions. */ /** * Example of how to hook in the Autoship Cloud options in custom * shop page template for simple products. * NOTE: This assumes you've added a xx_you_custom_template_before_add_to_cart_button_action * to your simple product template. */ function xx_print_autoship_options_for_simple_products(){ autoship_print_cart_autoship_options(); } add_action( 'xx_your_custom_template_before_add_to_cart_button_action', 'xx_print_autoship_options_for_simple_products', 10 ); /** * Example of how to hook in the Autoship Cloud options in custom * shop page template for variable products. * NOTE: This assumes you've added a xx_your_custom_template_before_single_variation_action * to your variable product template. */ function xx_print_autoship_options_for_variable_products(){ autoship_print_cart_autoship_options_variable(); } add_action( 'xx_your_custom_template_before_single_variation_action', 'xx_print_autoship_options_for_variable_products', 10 );