Digital experiences for all disciplines
New Landing › How can we help? › Atelier › continue shopping button to return to original page in shop
New Landing › How can we help? › Atelier › continue shopping button to return to original page in shop
- This topic has 9 replies, 2 voices, and was last updated 9 years by David Martin – Support.
-
Posted in: Atelier
-
August 28, 2015 at 6:52 pm #208530
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 buttonwhat 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
August 28, 2015 at 7:05 pm #208533Hi,
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 folderatelier/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.August 31, 2015 at 5:13 am #208747Hi 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
September 1, 2015 at 10:35 am #209081Hi 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
September 1, 2015 at 11:19 am #209101hi 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
September 1, 2015 at 11:32 am #209116Hi 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 folderatelier/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.September 1, 2015 at 11:34 am #209118sorry 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.
September 1, 2015 at 11:36 am #209120Ok, no problem. Thanks.
September 1, 2015 at 11:36 am #209121many thanks! i see i have a lot of evening homework ahead of me for the next month!
cheers
ali
September 1, 2015 at 11:40 am #209125Hi Ali,
Yeah, I have a few languages on my evening todo list also 🙂
– David.
-
Posted in: Atelier
You must be logged in and have valid license to reply to this topic.