WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
redirect after adding to cart (3 posts)

  1. logovaz
    Member
    Posted 1 year ago #

    Help set up a redirect after adding product to cart. is it possible to redirect after adding to cart customized for each product separately. As I understand this part of the code in the file woocommerce-funtstions.php responsible for a redirect after adding to cart
    // Redirect to cart option
    elseif (get_option('woocommerce_cart_redirect_after_add')=='yes' && $woocommerce->error_count() == 0) {
    wp_safe_redirect( $woocommerce->cart->get_cart_url('') );
    exit;
    }
    Is it possible to somehow convert it to this function would take the information about the link redirects for each product separately and not for the entire store. Sorry for my English. I use a translator.

    http://wordpress.org/extend/plugins/woocommerce/

  2. royho
    Member
    Posted 1 year ago #

    Yes anything is possible however this is quite custom to your application. I would suggest you add some kind of custom meta information to your product to state if this product should redirect or not. Then in your product template do a condition check for this meta and perhaps put a hidden value in an input tag. Then hunt for a callback within the add to cart.js and bind a function to that callback to look for the input hidden field's value and perform your re-direct from there.

  3. logovaz
    Member
    Posted 1 year ago #

    As far as I knew. I have to create a field such as "link". insert a reference to the value of such http://musite.ru/1 . And redirect to it after a function to add to the cart. I can not figure out how to catch the end of the function to add product to cart in your single-produtst.php. because the output <?php echo get_post_meta($post->ID, "link", $single = true); ?> only works in single-produtst.php
    Just thought there is a simpler solution is just built-in function redirect, you can add to any product one additional field and change the function to

    elseif (get_option('woocommerce_cart_redirect_after_add')=='yes' && $woocommerce->error_count() == 0)
    {wp_safe_redirect( 'field');
    exit;
    }
    Sorry again for my english

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.