New Landing How can we help? Atelier continue shopping button to return to original page in shop

Viewing 10 posts - 1 through 10 (of 10 total)
  • Posted in: Atelier
  • #208530
    alibey
    Member
    Post count: 179

    a number of testers (who in the real word are my client’s existing customers) asked for this feature today

    1) they are in shop/catalog
    2) add a product to the shopping cart
    3) change something in the shopping cart and save
    4) click on return to shopping button

    what they want is to return to the page containing the item where they started off from

    is this possible without guru level php custom programming?

    thx

    ali

    #208533
    David Martin – Support
    Moderator
    Post count: 20834

    Hi,

    By default this will return to the shop base you set in the WooCommerce => Settings => Products => Display.

    To change this you would need to customise the template cart.php found in the theme folder atelier/wooocomerce/cart.

    You would need to use PHP to do this, you would likely need to detect the referring page URL and then pass that as the URL for the button link.

    You can request this customisation here from the developers at WerkPress: http://www.swiftideas.com/customization/

    Thanks,
    David.

    #208747
    alibey
    Member
    Post count: 179

    Hi David You can do this without resorting to PHP! Just a few lines of simple JS without mucking about with server files.
    Here’s how:

    window.onload = function() {
    prepEventHandler();
    }

    function prepEventHandler () {

    var myClass = document.getElementsByClassName(‘continue-shopping’);
    myClass[0].addEventListener(“click”, function(e) {
    e.preventDefault();
    window.location.href = document.referrer;
    });
    }

    There is an even faster method of implementing this “customization” (which should have been there from the start, IMHO) that takes fewer lines of code and only 1 func and does not make use of preventDefault.

    Cheers,

    Ali

    #209081
    David Martin – Support
    Moderator
    Post count: 20834

    Hi Ali,

    Glad you also found a JS way of doing it. One thing to note, rarely some browsers or people disable JS which is why PHP would be ideal – but it looks like you have it covered for either option anyhow.

    – David

    #209101
    alibey
    Member
    Post count: 179

    hi david
    well, my understanding of the js browser disable is (my source is smashing magazine) that very few people do that anymore.
    i know i dont, though i used to 10 years ago.

    re this little js function, but not on class “return-to-shop” or class “wc-backward” — if you have an empty cart, and then with to simply go back to where you were, it would be nice if the return to shop to you back the same way via referrer

    for some reason, this does not work (ie create a new function to handle that)

    re php obviously a new version is coming out in a month or two, maybe i should spend a few hours an evening learning it, and then maybe try to write a plug in such as one to customize comments or notices. might be worth it, though i am not a fan of languages that ignore the separation of concerns in the MVC model — if I understand php correctly, which obviously not knowing it, i don’t really.

    another thing php would be useful for is having the ability to create a special “insurance fee” for products over $100 that would be applied automatically as a line item, currently i cannot do that. (my client is already baking in the cost for 0 tax for out of shipping — per current florida law — tax and free shipping) some of her items costs hundreds of dollars, and insurance is reqired for such items.

    cheers,

    ali

    #209116
    David Martin – Support
    Moderator
    Post count: 20834

    Hi Ali,

    Hopefully it’s not something people do often, but you never know!

    As WordPress is primarily PHP, I would suggest if you can get into it will benefit you, sounds like you have a good developer background.

    Regarding your cart link back query, the quickest way would be open cart.php found in the theme folder atelier/wooocomerce/cart, replace line 155 with the below example.

    				<?php $referer = esc_url_raw( $_SERVER['HTTP_REFERER'] ); ?>
    				<?php if ( $referer ) : ?>
    					<a class="continue-shopping accent" href="<?php echo $referer; ?>"><?php _e('Continue shopping', 'swiftframework'); ?></a>
    				<?php else : ?>
    					<a class="continue-shopping accent" href="<?php echo get_permalink( wc_get_page_id( 'shop' ) ); ?>"><?php _e('Continue shopping', 'swiftframework'); ?></a>
    				<?php endif; ?>

    Thanks,
    David.

    #209118
    alibey
    Member
    Post count: 179

    sorry the prose above is a little disconnected – i wrote a duplicate function to handle when you return to the referrer page when the cart is empty and you click the return to shop button. however, the classes i see associated with this button are not being listened to or picked up by the event handling. not sure why. will investigate later.

    #209120
    David Martin – Support
    Moderator
    Post count: 20834

    Ok, no problem. Thanks.

    #209121
    alibey
    Member
    Post count: 179

    many thanks! i see i have a lot of evening homework ahead of me for the next month!

    cheers

    ali

    #209125
    David Martin – Support
    Moderator
    Post count: 20834

    Hi Ali,

    Yeah, I have a few languages on my evening todo list also 🙂

    – David.

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in and have valid license to reply to this topic.

License required for the following item
Login and Registration Log in · Register