is_purchasable. Closes #1331.
This commit is contained in:
parent
714f441ace
commit
cedcca7fe7
|
@ -667,15 +667,9 @@ class WC_Cart {
|
|||
if ( $product_data->is_sold_individually() )
|
||||
$quantity = 1;
|
||||
|
||||
// Type/Exists check
|
||||
if ( $product_data->is_type('external') || ! $product_data->exists() ) {
|
||||
$woocommerce->add_error( __('This product cannot be purchased.', 'woocommerce') );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Price set check
|
||||
if( $product_data->get_price() === '' ) {
|
||||
$woocommerce->add_error( __('This product cannot be purchased - the price is not yet set.', 'woocommerce') );
|
||||
// Check product is_purchasable
|
||||
if ( ! $product_data->is_purchasable() ) {
|
||||
$woocommerce->add_error( __('Sorry, this product cannot be purchased.', 'woocommerce') );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -172,6 +172,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
|
|||
* Tweak - Added generate_title_html() to settings API
|
||||
* Tweak - PayPal standard: No longer using shipping_1 because a) paypal ignore it if *any* shipping rules are within paypal, b) paypal ignore anyhing over 5 digits, so 999.99 is the max
|
||||
* Tweak - Optimised dashboard icons for retina displays
|
||||
* Tweak - added is_purchasable class method for products
|
||||
* Fix - Removed session_name from 1.6 to prevent issues when other plugins start a session first. Instead, added a KB article on how to do it manually (if needed, this is an edge case) - http://wcdocs.woothemes.com/codex/extending/multiple-installs-on-one-domain-sessions-conflictsession-sharing-workaround/
|
||||
* Fix - Product categories shortcode loop
|
||||
* Fix - selected state for variation options
|
||||
|
|
|
@ -2,20 +2,20 @@
|
|||
/**
|
||||
* Loop Add to Cart
|
||||
*/
|
||||
|
||||
global $product;
|
||||
|
||||
if( $product->get_price() === '' && $product->product_type != 'external' ) return;
|
||||
global $product;
|
||||
|
||||
if ( $product->get_price() === '' && $product->product_type != 'external' ) return;
|
||||
?>
|
||||
|
||||
<?php if ( ! $product->is_in_stock() ) : ?>
|
||||
|
||||
|
||||
<a href="<?php echo apply_filters( 'out_of_stock_add_to_cart_url', get_permalink( $product->id ) ); ?>" class="button"><?php echo apply_filters( 'out_of_stock_add_to_cart_text', __( 'Read More', 'woocommerce' ) ); ?></a>
|
||||
|
||||
<?php else : ?>
|
||||
|
||||
<?php
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
switch ( $product->product_type ) {
|
||||
case "variable" :
|
||||
$link = apply_filters( 'variable_add_to_cart_url', get_permalink( $product->id ) );
|
||||
|
@ -34,7 +34,7 @@ if( $product->get_price() === '' && $product->product_type != 'external' ) retur
|
|||
$label = apply_filters( 'add_to_cart_text', __('Add to cart', 'woocommerce') );
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
printf('<a href="%s" rel="nofollow" data-product_id="%s" class="add_to_cart_button button product_type_%s">%s</a>', $link, $product->id, $product->product_type, $label);
|
||||
|
||||
?>
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
/**
|
||||
* Simple Product Add to Cart
|
||||
*/
|
||||
|
||||
|
||||
global $woocommerce, $product;
|
||||
|
||||
if( $product->get_price() === '') return;
|
||||
if ( $product->get_price() === '' ) return;
|
||||
?>
|
||||
|
||||
<?php
|
||||
<?php
|
||||
// Availability
|
||||
$availability = $product->get_availability();
|
||||
|
||||
|
||||
if ($availability['availability']) :
|
||||
echo apply_filters( 'woocommerce_stock_html', '<p class="stock '.$availability['class'].'">'.$availability['availability'].'</p>', $availability['availability'] );
|
||||
endif;
|
||||
|
@ -20,14 +20,14 @@ if( $product->get_price() === '') return;
|
|||
<?php if ( $product->is_in_stock() ) : ?>
|
||||
|
||||
<?php do_action('woocommerce_before_add_to_cart_form'); ?>
|
||||
|
||||
|
||||
<form action="<?php echo esc_url( $product->add_to_cart_url() ); ?>" class="cart" method="post" enctype='multipart/form-data'>
|
||||
|
||||
<?php do_action('woocommerce_before_add_to_cart_button'); ?>
|
||||
|
||||
<?php
|
||||
if ( ! $product->is_sold_individually() )
|
||||
woocommerce_quantity_input( array( 'min_value' => 1, 'max_value' => $product->backorders_allowed() ? '' : $product->get_stock_quantity() ) );
|
||||
<?php
|
||||
if ( ! $product->is_sold_individually() )
|
||||
woocommerce_quantity_input( array( 'min_value' => 1, 'max_value' => $product->backorders_allowed() ? '' : $product->get_stock_quantity() ) );
|
||||
?>
|
||||
|
||||
<button type="submit" class="single_add_to_cart_button button alt"><?php echo apply_filters('single_add_to_cart_text', __('Add to cart', 'woocommerce'), $product->product_type); ?></button>
|
||||
|
@ -35,7 +35,7 @@ if( $product->get_price() === '') return;
|
|||
<?php do_action('woocommerce_after_add_to_cart_button'); ?>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
<?php do_action('woocommerce_after_add_to_cart_form'); ?>
|
||||
|
||||
|
||||
<?php endif; ?>
|
Loading…
Reference in New Issue