How can I show an empty WooCommerce cart? [closed]
global $woocommerce; $count = $woocommerce->cart->cart_contents_count; This should be the variable you’d want to work with. Try var_dump on this to display its value.
global $woocommerce; $count = $woocommerce->cart->cart_contents_count; This should be the variable you’d want to work with. Try var_dump on this to display its value.
you have to create another request for variation. $variation_data = [ ‘regular_price’ => ‘15.00’, ‘image’ => [ ‘src’ => ‘https://shop.local/path/to/image_size_l.jpg’, ], ‘attributes’ => [ [ ‘id’ => 5, ‘option’ => ‘L’, ], ], ]; $this->woocommerce->post( “products/$product->id/variations”, $variation_data );
First of all to make geolocation work properly go to WooCommerce > Status and check MaxMind GeoIP database option, if there is red checkmark follow the provided instructions to download the database. Then you can add this code to your theme (at the bottom of functions.php) or add it as a plugin or code snippet … Read more
So I ended up making a workaround because I still have no clue what’s happening. I changed the url to point to the product page and I’m using ol’good PHP to get the values and add the product with WooCommerce API. Here’s my code: if(isset($_GET[‘order’]) && $_GET[‘order’] == ‘true’) { $typo = isset($_GET[‘attribute_pa_typographie’]) ? $_GET[‘attribute_pa_typographie’] … Read more
What you’ve done here is changing slug for products. For example : http://localhost:8080/shop/product-category/sample-product as explained in WP, but not your Woocommerce home. Change the base to base default in permalinks settings. Then read after 🙂 If you want to change your “Shop Homepage” go to http://localhost:8080/wp-admin/admin.php?page=wc-settings&tab=products§ion=display That’s the good way to do it !
On category archives (or any the archive for any taxonomy term) you can get the current term with get_queried_object(). If you just need the ID you can use get_queried_object_id(). If you want to output the name of the term, you can use single_term_title(). Keep in mind that archive-product.php will also be used for the Shop … Read more
So the answer to this is instead of placing the code in your functions.php, you create a “woocommerce” folder in your theme folder, and place the “cart” folder and the “cart.php” template file from the woocommerce plugin inside of that. Then you place the same code as in the “woocommerce_before_calculate_totals” action inside the loop of … Read more
I figured out that this happened because the attributes did not exist in WooCommerce yet. First you have to add all attributes and their values, then generate and add variations. Then it should work: // Create an array of the attributes we want to add $attributes = array( “attribute_1” => array( “slug” => “attribute_1”, “label” … Read more
Here’s a plugin that deals with this fairly effectively. https://github.com/haydenw/woocommerce-product-sorting
On woocommerce_available_variation hook the $args array doesn’t include input_value argument. Also You are not using has_term() conditional function in the right way for product categories. So try the following code instead: add_filter( ‘woocommerce_available_variation’, ‘customizing_available_variation’, 10, 3 ); // Variations function customizing_available_variation( $args, $product, $variation ) { if( has_term( ‘flyer’, ‘product_cat’, $product->get_id() ) ) { $args[‘max_qty’] … Read more