Product option for customise the button text for external products

This commit is contained in:
Mike Jolley 2012-02-24 16:05:17 +00:00
parent 16cfdbd345
commit f0d4d8cb63
3 changed files with 9 additions and 1 deletions

View File

@ -60,6 +60,9 @@ function woocommerce_product_data_box() {
// External URL
woocommerce_wp_text_input( array( 'id' => '_product_url', 'label' => __('Product URL', 'woocommerce'), 'placeholder' => 'http://', 'description' => __('Enter the external URL to the product.', 'woocommerce') ) );
// Button text
woocommerce_wp_text_input( array( 'id' => '_button_text', 'label' => __('Button text', 'woocommerce'), 'placeholder' => __('Buy product', 'woocommerce'), 'description' => __('This text will be shown on the button linking to the external product.', 'woocommerce') ) );
echo '</div>';
@ -767,6 +770,7 @@ function woocommerce_process_product_meta( $post_id, $post ) {
if ($product_type=='external') :
if (isset($_POST['_product_url']) && $_POST['_product_url']) update_post_meta( $post_id, '_product_url', esc_attr($_POST['_product_url']) );
if (isset($_POST['_button_text']) && $_POST['_button_text']) update_post_meta( $post_id, '_button_text', esc_attr($_POST['_button_text']) );
endif;

View File

@ -171,6 +171,8 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
* Fixed record_product_sales
* Fix order tracking page
* Fix dates for orders
* Made links in customer notes clickable links
* Product option for customise the button text for external products
= 1.4.4 - 18/02/2012 =
* Fix for remove coupon links after ajax update of shipping

View File

@ -6,12 +6,14 @@
global $woocommerce, $product;
$product_url = get_post_meta( $product->id, '_product_url', true );
$button_text = get_post_meta( $product->id, '_button_text', true );
if (!$product_url) return;
if (!$button_text) $button_text = __('Buy product', 'woocommerce');
?>
<?php do_action('woocommerce_before_add_to_cart_button'); ?>
<p class="cart"><a href="<?php echo $product_url; ?>" rel="nofollow" class="button alt"><?php echo apply_filters('single_add_to_cart_text', __('Buy product', 'woocommerce'), $product->product_type); ?></a></p>
<p class="cart"><a href="<?php echo $product_url; ?>" rel="nofollow" class="button alt"><?php echo apply_filters('single_add_to_cart_text', $button_text, $product->product_type); ?></a></p>
<?php do_action('woocommerce_after_add_to_cart_button'); ?>