eastanglianevents
Forum Replies Created
-
Forum: Plugins
In reply to: [WooCommerce Cart Stock Reducer] HooksHi,
I’m a bit new to all this.. I can see in your class php file you use ‘get_virtual_stock_available’.. I could then find the difference between the real stock. How would I be able to get the virtual stock available in the functions.php file?dDean.
Forum: Plugins
In reply to: [HyperDB] Will HyperDB still work with WordPress v5.1?I have it working on our test site using wordpress 5.1. All seems to work correctly, I’m going to install onto the live site.
Forum: Plugins
In reply to: [WooCommerce Cart Stock Reducer] HooksSorry, yeah… If someone places the last item in their cart everyone else gets the soldout message even thou they have not been through the checkout yet. If the cart times out it then places back into stock for others to purchase. I would like to be able to put a different message other than sold out while its in the cart and not purchased so people can wait to see if they can purchase it.
Thanks,
DEan.Forum: Plugins
In reply to: [WooCommerce Cart Stock Reducer] HooksThe below is what I’m using at the minute, if I can not display soldout and have something else when stock is in a cart.
Thanks,
Dean.add_filter( ‘woocommerce_product_add_to_cart_text’, ‘customizing_add_to_cart_button_text’, 10, 2 );
add_filter( ‘woocommerce_product_single_add_to_cart_text’, ‘customizing_add_to_cart_button_text’, 10, 2 );
function customizing_add_to_cart_button_text( $button_text, $product ) {
$sold_out = __( “Sold Out”, “woocommerce”);
$incart = __( “Already in Cart”, “woocommerce”);
$addcart = __( “Add to Cart”, “woocommerce”);
$availability = $product->get_availability();
$stock_status = $availability[‘class’];
// Only for variable products on single product pages
if ( $product->is_type(‘variable’) && is_product() )
{
?>
<script>
jQuery(document).ready(function($) {
$(‘select’).blur( function(){
if( ” != $(‘input.variation_id’).val() && $(‘p.stock’).hasClass(‘out-of-stock’) )
$(‘button.single_add_to_cart_button’).html(‘<?php echo $sold_out; ?>’);
else
$(‘button.single_add_to_cart_button’).html(‘<?php echo $button_text; ?>’);
$(‘button.single_add_to_cart_button’).html(‘<?php echo $button_text; ?>’);console.log($(‘input.variation_id’).val());
});
});
</script>
<?php
}
// For all other cases (not a variable product on single product pages)
elseif ( ! $product->is_type(‘variable’) && ! is_product() )
{
if($stock_status == ‘out-of-stock’){
$button_text = $sold_out;
return $button_text;}
else
$cartidnum = 0;
foreach( WC()->cart->get_cart() as $values ) {
$products_ids_array[] = $values[‘product_id’];
$_product = $values[‘product_id’];
if( $product->get_id() == $products_ids_array[$cartidnum] ) {
$button_text = $incart;
return $button_text;
}
else
$cartidnum++;
}
}
$button_text = $addcart;
return $button_text;
}