Why is B = numpy.dot(A,x) so much slower looping through doing B[i,:,:] = numpy.dot(A[i,:,:],x) )?

numpy.dot only delegates to a BLAS matrix multiply when the inputs each have dimension at most 2: #if defined(HAVE_CBLAS) if (PyArray_NDIM(ap1) <= 2 && PyArray_NDIM(ap2) <= 2 && (NPY_DOUBLE == typenum || NPY_CDOUBLE == typenum || NPY_FLOAT == typenum || NPY_CFLOAT == typenum)) { return cblas_matrixproduct(typenum, ap1, ap2, out); } #endif When you stick your … Read more

Get custom product attributes in Woocommerce

Edited: The woocommerce_get_product_terms is deprecated since Woocommerce version 3 Go with the following as @datafeedr wrote in his answer: global $product; $koostis = array_shift( wc_get_product_terms( $product->id, ‘pa_koostis’, array( ‘fields’ => ‘names’ ) ) ); or even more compact: global $product; $koostis = $product->get_attribute( ‘pa_koostis’ ); Original answer: $result = array_shift(woocommerce_get_product_terms($product->id, ‘pa_koostis’, ‘names’));

Disable add to cart button for an array of products IDs in WooCommerce

Updated for WooCommerce 3+ Use in_array() instead like: add_filter( ‘woocommerce_variation_is_purchasable’, ‘filter_is_purchasable’, 10, 2 ); add_filter(‘woocommerce_is_purchasable’, ‘filter_is_purchasable’, 10, 2); function filter_is_purchasable($is_purchasable, $product ) { if( in_array( $product->get_id(), not_purchasable_ids() ) { return false; } return is_purchasable; } Where not_purchasable_ids() is the function that returns an array of non purchasable products Ids (here simplified): function not_purchasable_ids() { return … Read more

Hide variation info from cart item title in WooCommerce 3+

This filter should work returning a false value for $should_include_attributes first argument in woocommerce_product_variation_title_include_attributes filter hook this way: add_filter( ‘woocommerce_product_variation_title_include_attributes’, ‘custom_product_variation_title’, 10, 2 ); function custom_product_variation_title($should_include_attributes, $product){ $should_include_attributes = false; return $should_include_attributes; } Code goes in function.php file of your active child theme (or theme) or also in any plugin file. It should just work … Read more

Updating product stock programmatically in Woocommerce 3

Update 2 Since woocommerce 3 “outofstock” product status is saved in 2 locations: As post meta data for _stock_status meta key (just as before). As a post term name outofstock remaining to product_visibility custom taxonomy That means that you missed just a step (the step 3): $out_of_stock_staus=”outofstock”; // 1. Updating the stock quantity update_post_meta($product_id, ‘_stock’, … Read more

How to do version numbers? [closed]

[major].[minor].[release].[build] major: Really a marketing decision. Are you ready to call the version 1.0? Does the company consider this a major version for which customers might have to pay more, or is it an update of the current major version which may be free? Less of an R&D decision and more a product decision. minor: … Read more

Get in WooCommerce cart the product ID of a cart item

To get the product ID of each cart item in the foreach loop (for a simple product): foreach( WC()->cart->get_cart() as $cart_item ){ $product_id = $cart_item[‘product_id’]; } If it’s a variable product, to get the variation ID: foreach( WC()->cart->get_cart() as $cart_item ){ $variation_id = $cart_item[‘variation_id’]; } Or for both cases (where $cart_item[‘data’] is the WC_Product Object … Read more

Check if a user/guest has purchased specific products in WooCommerce

Lighter and improved code version in HERE that handle multiple product IDs Updated (compatibility for Woocommerce 3+) Yes it’s possible, writing a conditional function that returns “true” if current customer has already bought specifics defined products IDs. This code goes on function.php file of your active child theme or theme. Here is the conditional function: … Read more