shanerutter
Forum Replies Created
-
There is no need for the warning to be public, it should only display if you are logged in as an admin. The public does not need to see a big red message telling them somthing has gone wrong.
Simular issue, the token keeps expring and just shows a red message on the website to all users.
https://snipboard.io/bKx2rq.jpg
Does the token not auto renew? Below is the text as its not easily readable.
Error validating access token: Session has expired on Sunday, 22-Nov-20 10:54:25 PST. The current time is Wednesday, 25-Nov-20 02:48:55 PST.
- This reply was modified 5 years, 8 months ago by shanerutter.
- This reply was modified 5 years, 8 months ago by shanerutter.
Forum: Plugins
In reply to: [Stock Locations for WooCommerce] Rest apiHi, I needed the ability to use the REST api also, as you say you can use the meta_data way to set the actual location stock level. But I also need the abilty to enable / disable the stock locations as well. So I quickly made this.
Will show “stock_location” when get products/*
Allow update stock_locations when you PUT products/*Its a temp solutuon until Alex get somthing into the actual plugin 🙂
/* * Include stock_location */ function custom_woocommerce_rest_prepare_product($response, $post) { $post_id = is_callable(array($post, 'get_id')) ? $post->get_id() : (!empty($post->ID) ? $post->ID : null); if (empty($response->data['stock_locations'])) { $terms = array(); foreach (wp_get_post_terms($post_id, 'location') as $term) { $terms[] = array( 'id' => $term->term_id, 'name' => $term->name, 'slug' => $term->slug, ); } $response->data['stock_locations'] = $terms; } return $response; } add_filter('woocommerce_rest_prepare_product', 'custom_woocommerce_rest_prepare_product', 10, 2); // WC 2.6.x add_filter('woocommerce_rest_prepare_product_object', 'custom_woocommerce_rest_prepare_product', 10, 2); // WC 3.x /* * Update stock_location */ function custom_woocommerce_rest_insert_product($post, $request) { if (isset($request['stock_locations']) && is_array($request['stock_locations']) && sizeof($request['stock_locations'])) { $terms = array_map('absint', $request['stock_locations']); wp_set_object_terms($post->id, $terms, 'location'); } } add_action('woocommerce_rest_insert_product', 'custom_woocommerce_rest_insert_product', 10, 3); // WC 2.6.x add_action('woocommerce_rest_insert_product_object', 'custom_woocommerce_rest_insert_product', 10, 3); // WC 3.x