Categories not shown in admin after adding woocommerce products via wp wc cli
After opening issue on woocommerce github page and authors reaction. The solution is wp wc product create –name=”Product Name” –categories=”[ { “id” : 21 } ]” –user=admin
After opening issue on woocommerce github page and authors reaction. The solution is wp wc product create –name=”Product Name” –categories=”[ { “id” : 21 } ]” –user=admin
Internally, WooCommerce uses WordPress’ wp_safe_redirect() which does not allow redirects to external hosts. In order to get around this, we must add our desired host to the whitelist. The whitelist can be modified using the allowed_redirect_hosts which has been demonstrated below: /** * Adds example.com to the list of allowed hosts when redirecting using wp_safe_redirect() … Read more
Yes, after an order created you can get details of it. The woocommerce_payment_complete hook is fired when the payment is completed. The only variable passed is the order id, though from that you can get the order object, and ultimately the user. add_action( ‘woocommerce_order_status_completed’, ‘so_payment_complete’ ); function so_payment_complete( $order_id ){ $order = wc_get_order( $order_id ); … Read more
add_action(‘woocommerce_after_add_to_cart_button’,’cmk_additional_button’); function cmk_additional_button() { echo ‘<button type=”submit” class=”button alt”>Change me please</button>’; } add this code in your Child theme functions.php Try this code
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