Attempting to list all product categories and the price range of all products within them

You can get using SQL query – global $wpdb; $results = $wpdb->get_col( ” SELECT pm.meta_value FROM {$wpdb->prefix}term_relationships as t INNER JOIN {$wpdb->prefix}term_taxonomy as tt ON tr.term_taxonomy_id = tt.term_taxonomy_id INNER JOIN {$wpdb->prefix}terms as t ON tr.term_taxonomy_id = t.term_id INNER JOIN {$wpdb->prefix}postmeta as pm ON tr.object_id = pm.post_id WHERE tt.taxonomy LIKE ‘product_cat’ AND t.term_id = {$term->term_id} AND … Read more

Remove Zero Money From Previews Order woocommerce

You can update new price using below method – $order_id = 123; $order = wc_get_order( $order_id ); foreach( $order->get_items() as $item_id => $item ){ $new_product_price = 30; $product_quantity = (int) $item->get_quantity(); $new_line_item_price = $new_product_price * $product_quantity; $item->set_subtotal( $new_line_item_price ); $item->set_total( $new_line_item_price ); $item->save(); // Save line item data } $order->calculate_totals();

How to redirect users to the last page viewed

Give this a try… function save_url_before_login() { if(!is_user_logged_in()) { $_SESSION[‘referer_url’] = get_the_permalink(); } add_action(‘wp’, ‘save_url_before_login’); and: function redirect_after_login() { $redirect_url = home_url(“https://wordpress.stackexchange.com/”); if (isset($_SESSION[‘referer_url’])) { $redirect_url = $_SESSION[‘referer_url’]; unset($_SESSION[‘referer_url’]); } return $redirect_url; } add_filter(‘login_redirect’, ‘redirect_after_login’);