autoship_checkout_recurring_variable_discount_string (function)

( src/product-page.php) Function which returns the Autoship option HTML. It takes the (WooCommerce) $product_id as its parameter.

Code

/**
* Retrieves the HTML for the Autoship and Save Variation extended text
*
* @param int    $product_id.      The wc product or variation id.
*/
function autoship_checkout_recurring_variable_discount_string( $product_id ){

  $product = wc_get_product( $product_id );

  $strings['autoship_save_string'] = sprintf( '<span class="autoship-save">%s</span>',
  apply_filters( 'autoship_radio_label', autoship_translate_text(  'Autoship and Save', true ),
  'yes', true, $product ) );
  $strings['autoship_string'] = sprintf( '<span class="autoship">%s</span>',
  apply_filters( 'autoship_radio_label', autoship_translate_text( 'Autoship', true ),
  'yes', false, $product ) );

  ob_start();?>

  <span class="autoship-discount-label">
      <span class="autoship-save"><?php echo $strings['autoship_save_string']; ?></span>
      <span class="autoship-custom-percent-discount-str"></span>:
      <span class="autoship-checkout-price"></span>
  </span>
  <span class="autoship-no-discount-label">
      <span class="autoship"><?php echo $strings['autoship_string']; ?></span>
  </span>

  <?php
  return apply_filters( 'autoship_checkout_recurring_variable_discount_string_html', ob_get_clean(), $product, $strings );

}

Still need help? Contact Us Contact Us