How to know the page from which a product is added to the cart? – WooCommerce

Please try below code : In this display only page/post URL and page/post ID. You need to store page ID/URL and can get from database. NOTE : This is code working only in details page. function custom_to_cart_item( $cart_item_data, $product_id, $variation_id ) { $page_url = wp_get_referer(); $page_id = url_to_postid( $page_url ); } add_filter( ‘woocommerce_add_cart_item_data’, ‘custom_to_cart_item’, 10, … Read more

Need to forward Data from WooCommerce Webhook sent to same site WordPress REST API custom endpoint

I figured out it could be an Authorization problem, then I looked the WooCommerce webhook functions and fount where the delivery is executed: /wp-content/plugins/woocommerce/includes/class-wc-webhook.php I hard coded my Authorization header after line # 303 in the deliver() function: ‘headers’ => array( ‘Content-Type’ => ‘application/json’, ‘Authorization’ => ‘Basic bmNkaWgdrGFsOiNIb25kdXJhczIwMThTUFMh’, ), Now I need to calculate the … Read more

WooCommerce – Show different terms and conditions for different user roles

The Wholesale role was created as part of a plugin that’s been installed (WooCommerce Wholesale Pro Suite). Currently, the T&C link is being displayed using the standard WooCommerce functionality. But what I’ve done is amend the terms.php file, within the checkout folder of the WooCommerce templates (copying it to my theme folder) and I’ve found … Read more

How to display Woocommerce products list by tag

Finally Solved my problem My previous code was only for category wise product but when using tag it should be post. for better explain someone can please explain about the whole process. <?php $args = array( ‘number’ => $number, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ‘hide_empty’ => $hide_empty, ‘include’ => $ids ); $product_tags = get_terms( … Read more

Add Previous | Next arrows near to related products

Not sure how your Previous and Next arrows are setup and/or being pulled in, but at a basic level you can add in the product_cat to the previous_post_link() and next_post_link() calls: https://codex.wordpress.org/Function_Reference/previous_post_link <?php previous_post_link( ‘Previous: %link’, ‘%title’, true, ”, ‘product_cat’ ); ?>