Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimjasson/71bc03642697f3b0ca2df43de2491eaa to your computer and use it in GitHub Desktop.
Save jimjasson/71bc03642697f3b0ca2df43de2491eaa to your computer and use it in GitHub Desktop.
<?php
/**
* Plugin Name: All Products for WooCommerce Subscriptions - Display one-time purchase option price
* Plugin URI: https://woocommerce.com/products/all-products-for-woocommerce-subscriptions/
* Description: Use this snippet to display the product price next to the one-time option for Simple Products.
* Version: 1.0
* Author: SomewhereWarm
* Author URI: http://somewherewarm.gr/
* Developer: Jason Kytros
*
*
* Copyright: © 2019 Jason Kytros (jask@somewherewarm.gr).
* License: GNU General Public License v3.0
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
add_filter( 'wcsatt_single_product_options', 'sw_wc_apfs_display_option_price', 10, 3 );
function sw_wc_apfs_display_option_price( $options, $subscription_schemes, $product ) {
if ( 'one-time-option' === $options[0][ 'class' ] ) {
// Retrive formatted product price.
$product_price_array = explode( '<small class="wcsatt-sub-options">', $product->get_price_html(), 2 );
$product_price = $product_price_array[0];
$options[0][ 'description' ] = $options[0][ 'description' ] . ' ' . $product_price;
}
return $options;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment