tondegier
Forum Replies Created
-
Forum: Plugins
In reply to: [WooCommerce Cart Stock Reducer] Sold individually not workingThis solution works we me now but is not nice comparing $ignore.
public function quantity_input_args( $args, $product ) {
if ( ‘quantity’ === $args[ ‘input_name’ ] ) {
$ignore = false;
} else {
// Ignore users quantity when looking at pages like the shopping cart
$ignore = true;
}
if ( $product->sold_individually ) {
$args[ ‘max_value’ ] = 1;
} else {
$args[ ‘max_value’ ] = $this->get_virtual_stock_available( $product, $ignore );
}
return $args;
}Forum: Plugins
In reply to: [WooCommerce Cart Stock Reducer] Cart stock reducer for variant productsHi James,
Not very nice, but do not know how to make it proper.
I added some extra line in the function to look for product backorder notification.
If found then skip error message.
Then backorder products are excluded from availablity check and stock reducer.Kind regards,
Tonpublic function add_cart_validation( $valid, $product_id, $quantity, $variation_id = null, $variations = array() ) {
$hostname = ” “;
$username = ” “;
$password = ” “;
$database = ” “;// connection
$conn = new mysqli($hostname, $username, $password, $database);if ( $this->item_managing_stock( $product_id, $variation_id ) ) {
$available = $this->get_stock_available( $product_id, $variation_id );$results = “SELECT meta_value FROM wp_postmeta WHERE post_id = ‘$product_id’ and meta_key = ‘_backorders’ and meta_value = ‘notify'”;
$backorder = $conn->query($results);if ( $q = $backorders->num_rows = 0 ) {
if ( $available < $quantity ) {
wc_add_notice( __( ‘Dit artikel en/of maat is niet meer beschikbaar’, ‘woocommerce-cart-stock-reducer’ ), ‘error’ );
$valid = false;
}
}
}
return $valid;Forum: Plugins
In reply to: [WooCommerce Cart Stock Reducer] Cart stock reducer for variant productsHi James,
Yes, we use this for clothing products we don’t have on stock, but purchase this customer specific.
So stock level is switched on and backorder order enabled.It would be a great plus if this is supported by your plugin.
Kind regards,
Ton de GierForum: Plugins
In reply to: [WooCommerce Cart Stock Reducer] Cart stock reducer for variant productsHi James,
You are right. It is working for variable products.
Only not working for product weith setting “Allow backorders” .
With this setting it should be possible to sell the product.
But with this add-on this is not possible.Kind regards,
Ton de Gier