product

Hide a specific Woocommerce products from loop if they are in cart

痴心易碎 提交于 2019-12-08 05:53:44
问题 I'm trying to write a hook that hides a specific product from the shop page if it's in the cart, but I can't seem to figure out two things. function find_product_in_cart() { $hide_if_in_cart = array(6121, 6107, 14202, 14203); $in_cart = false; foreach( WC()->cart->get_cart() as $cart_item ) { $product_in_cart = $cart_item['product_id']; foreach ( $hide_if_in_cart as $key => $value ) { if ( $product_in_cart === $value ) { $in_cart = true; } } if ( $in_cart ) { echo 'Product in cart'; } else {

Replace product image by a placeholder based on user roles in WooCommerce

╄→尐↘猪︶ㄣ 提交于 2019-12-08 05:44:29
问题 In WooCommerce I am using user roles to define what each user role can see. If the user is "customer" or "administrator", he is able to see the product image, otherwise he see WooCommerce default placeholder image. For that I use the code below: function woocommerce_product_get_image_id_callback( $value ) { global $current_user; if ( in_array( 'customer', (array) $current_user->roles )|| in_array( 'administrator', (array) $current_user->roles )) { return $value; } else { return false; } } add

Create a product from PHP - Magento

匆匆过客 提交于 2019-12-08 05:31:49
问题 A friend of mine created a magento webshop recently. He wants to have a few thousand products in his store and asked the manufacturer to give him some kind of data he could simple import to magento. The manufacturer said that he does not own something like that or doesn't want to give it out (I'm not 100% sure about this one). But he was allowed to use all the product information on his site to complete his webshop. So I wrote a webcrawler who grabs all the information. After researching a

Efficient way to compute Kronecker product of matrices with GSL

大兔子大兔子 提交于 2019-12-08 05:15:56
问题 The bottleneck of my algorithm is my function Kronecker Product called KPro: gsl_matrix *KPro(gsl_matrix *a, gsl_matrix *b) { int i, j, k, l; int m, p, n, q; m = a->size1; p = a->size2; n = b->size1; q = b->size2; gsl_matrix *c = gsl_matrix_alloc(m*n, p*q); double da, db; for (i = 0; i < m; i++) { for (j = 0; j < p; j++) { da = gsl_matrix_get (a, i, j); for (k = 0; k < n; k++) { for (l = 0; l < q; l++) { db = gsl_matrix_get (b, k, l); gsl_matrix_set (c, n*i+k, q*j+l, da * db); } } } } return

Cart products dissapear on refresh page Prestashop

好久不见. 提交于 2019-12-08 05:15:46
问题 since some weeks I have a problem with my Prestashop 1.4.0.12 When I add a product to cart, ajax works correctly and add the product very well. But, if I change page, or sometimes adding a product, the cart change deleting all products on refresh a new page. Sometimes I can move within some pages, but dissapears the products of the cart and later if I have a new cart returns to the old cart. Anybody knows about it? I think that the problem is on id_guest but I need to know if anyone have some

Get featured products in Woocommerce 3

放肆的年华 提交于 2019-12-08 05:12:58
问题 I want to add Featured products for upsell (or Recent Products OR Best Selling Products) in New order Email template. It works like Upsell with email marketing. How do I add it to woocommerce email template so that there is a section in the end of the email which shows my featured/Recent/best selling products. I tried using this code in my New order Email template but nothing works. I use all latest version of wordpress n woocommerce. $args = array( 'post_type' => 'product', 'meta_key' => '

Disabling Add to Cart Button for Specific WooCommerce Products

断了今生、忘了曾经 提交于 2019-12-08 05:09:57
问题 I'm trying to disable adding to cart certain products which have the "Call to Order" checkbox ticked (see code below) on the product editor. add_action( 'woocommerce_product_options_general_product_data', 'custom_general_product_data_custom_fields' ); /** * Add `Call to Order` field in the Product data's General tab. */ function custom_general_product_data_custom_fields() { // Checkbox. woocommerce_wp_checkbox( array( 'id' => '_not_ready_to_sell', 'wrapper_class' => 'show_if_simple', 'label'

Add custom field in products to display in cart, checkout and in orders

夙愿已清 提交于 2019-12-08 05:09:35
问题 I am using a Custom post type and integrated woocommerce on it, I am able to add an add-to-cart button on the pages and can add it to cart, so it works fine here is my code class WCCPT_Product_Data_Store_CPT extends WC_Product_Data_Store_CPT { /** * Method to read a product from the database. * @param WC_Product */ public function read( &$product ) { $product->set_defaults(); if ( ! $product->get_id() || ! ( $post_object = get_post( $product->get_id() ) ) || ! in_array( $post_object->post

Displaying price only when the variation is selected and discount in percentage relatively to the regular price

一个人想着一个人 提交于 2019-12-08 04:52:36
问题 I've this problem. Let me show pictures so I can explain better. Variation product selected but because all the variations have the same price the price do not show in the bottom: Variation product selected, because they have different PROMO prices they show on top and the regular-promo price after selection: What I need is that only after selected the variations the price is show in the bottom like the second image and calculation the discount between the promo variation price and the

Display WooCommerce products with a shortcode using a custom meta_query

爱⌒轻易说出口 提交于 2019-12-08 04:23:34
问题 I'm creating a flash sale website and I already display products according to date range on my home and shop pages. But I also want to display products according to a date range elsewhere and therefore using a shortcode. Here is my code: function testt($meta_query) { $today = current_time('Ymd'); $args = apply_filters('woocommerce_shortcode_products_query', array ( 'post_type' => 'product', 'numberposts' => -1, 'meta_query' => array( 'relation' => 'AND', 'start_clause' => array( 'key'=>'flash