Created
October 3, 2019 13:12
-
-
Save jimjasson/71bc03642697f3b0ca2df43de2491eaa to your computer and use it in GitHub Desktop.
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 | |
/** | |
* 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