I want to insert / change a link on my checkout page, but am not sure how to change the code so it appears correctly. Hoping someone might be able to shed some light. I research & tried a number of things, but kept getting error pages. All I am trying to do is change the "Cart" link to be another link. But since the cart link isn't formatted like a regular link, I'm not sure what to replace to get it to show properly. I want to just replace it with a regular URL (https://sprinly.com/subscription-plans).
Thanks in advance!!
add_action( 'woocommerce_checkout_before_order_review', 'my_wc_checkout_before_order_review', 10, 0 );
function my_wc_checkout_before_order_review() {
echo '<p class="return-to-cart">If you\'d like to change your subscription, go back to Cart. </p>';
}
You need to replace the PHP that is generating the cart link (WC()->cart->get_cart_url()) with the URL, like so:
add_action( 'woocommerce_checkout_before_order_review', 'my_wc_checkout_before_order_review', 10, 0 );
function my_wc_checkout_before_order_review() {
echo '<p class="return-to-cart">If you\'d like to change your subscription, go back to Cart. </p>';
}
Related
continue to shipping button text and continue to payment button text
in website woocommerce checkout is there any solution for this pls help me
SH1
Sh2
My website
Cosmeticsonlinehubb.pk
I have tried all plugins but still got not solution for this.
you can change by adding this code to your theme's functions.php
function my_custom_checkout_button_text() {
return 'My Custom Text';
}
add_filter( 'woocommerce_order_button_text', 'my_custom_checkout_button_text' );
You have to change the value which obviously is the My Custom Text to whatever you want.
Friendly, George
I am trying to display a button which will direct users to a different product but the URL of this button will be the same as the current URL but will append 2 added letters to the end of the URL. For example, I am on product URL mywebsite.com/products/super-awesome-product-abc and I want the button to link to mywebsite.com/products/super-awesome-product-abcdef. I have 100 products and I will be creating more over time. I would like a dynamic solution that will display the new URL regardless of what page/product they are on. The appended characters will always be the same. I will add that the appended "abc" and "abcdef" in my example are also the product SKU. Perhaps I can use this in the solution. I am adding these buttons to the /themes/mytheme/woocommerce-bookings/booking-form/datetime-picker.php file.
I believe this works for me. I placed the below code in my themes function.php file:
add_action( 'woocommerce_before_add_to_cart_form', 'booking_lastminute_button', 35 );
function booking_lastminute_button(){
global $product;
if( $product->get_sku() ) {
echo '<p class="lastminute-button">Click to find a better product</p>';
}
I am trying to change the name of a tab in product page of woocommerce to a different name.
I am trying to find which PHP file has that particular code but I am unable to do that. Have also used plugins like WhatTheFile (it said the product page is loaded from single-product.php, but I couldn't find the html to edit there) and String Locator and they couldn't help even. Please have a look at this video I made and you will better understand my problem.
https://www.dropbox.com/s/bruhb2n83lhfnp6/Code.mp4?dl=0
I am using G5Plus April theme
Thank you
you can add code like this in functions.php of your theme to customize the product description tab title. For more details, Link 1, Link 2
add_filter( 'woocommerce_product_tabs', 'woo_customize_tabs', 100, 1 );
function woo_customize_tabs( $tabs ) {
$tabs['description']['title'] = __( 'More Information' ); // Rename the description tab
return $tabs;
}
Hope this will helps you.
I am trying to AJAXify my Woocommerce cart but I am failing hard and I really can't find any help or documentation (I searched for days). So any help is desperately appreciated.
I tried two approaches:
Custom AJAX Function
When changing the quantity (on the cart page), a AJAX call is fired (-> admin-ajax.php) which triggers a function in my functions.php:
function setQty() {
global $woocommerce;
WC()->cart->set_quantity( $_POST['itemKey'], $_POST['quantity'], true);
echo json_encode(array('totalCount'=>WC()->cart->get_cart_contents_count(), 'total'=>$woocommerce->cart->total)); }
The echoed JSON String contains the correct number of items in cart but the total amount is 0. When I reload the page the altered quantity is not saved.
Same with
WC()->cart->add_to_cart($product_id, $quantity) or adding WC()->cart->calculate_totals()
I tried it this way so i can format the values I need to update my cart how i want.
What am I missing here in order to get the cart update saved?
The woocommerce built-in AJAX update function doesn't trigger, because I have a custom design and I think it needs a specific HTML-structure in order to work properly but i can't find any documentation or examples. Also I need the updated values (total amount, total count etc.) in a custom format. So far it just passes me "updated fragments" as predefined html code.
How do i need to build the HTML code of my cart.php that the ajax update will work? And how do i alter the returning values?
Thank you very much in advance.
I'm not sure what you'd like to update, but I guess you want to update the totals amount of products in the basket.
This example replaces and updates the HTML
Let's say you have a div where your total amount is in:
<div class="cart-totals"><?php echo WC()->cart->get_cart_contents_count(); ?></div>
Add this to your functions.php:
// Mini Cart update with AJAX
add_filter( 'woocommerce_add_to_cart_fragments', 'custom_cart_count_fragments', 10, 1 );
function custom_cart_count_fragments( $fragments ) {
$fragments['div.cart-totals'] = '<div class="cart-totals">' . WC()->cart->get_cart_contents_count() . '</div>';
return $fragments;
}
Note: You are replacing not adding
Is it a mini cart/counter you are trying to create or a full page to review/remove products?
If it is a mini-cart/cart counter you wanted, I've created a repo under https://github.com/samisonline/ajax_cart for you that has the basic functionality baked in. This may not be the exact format you're looking for, but it shows the woocommerce functionality at work, as well as the needed markup for AJAX to work!
I've seen many tutorials dealing on how to customize woocommerce's checkout page by adding or removing fields.
But what I want is to place a link or button on the Woocommerce Checkout page saying "Return to Cart" (obviously linking to the cart page) but I want it placed just after the "Your Order" section, (the section where you review your order). I want it there because I want it along with a text saying something like "If you want to change your order return to Cart".
If I edit the actual checkout page and add the link there, it shows all the way to the bottom so maybe I have to add code to the theme's functions file? Any guidance will be greatly appreciated.
Thank you.
EDIT:
Ok, I've found a very crappy way of doing it.
I just added this line to the review-order.php file located in woocommerce/templates/checkout/ , right after the shop_table class:
<?php echo "<strong>If you'd like to change your order, go back to <a href='http://www.mysite.com/cart/'>My Cart</a></strong><br />"; ?>
This does the trick, but everytime I update woocommerce I will have to added it again.
Any suggestion of a more practical and intelligent way of doing it?
Create a child theme.
Put this in the child theme's functions.php
/**
* Add link back to cart after order review on Checkout
*/
add_action( 'woocommerce_review_order_before_payment', 'my_back_to_cart_link' );
function my_back_to_cart_link(){
//get the cart link
global $woocommerce;
$cartUrl = $woocommerce->cart->get_cart_url();
//the HTML markup to add
$backToCartLink="<p class='backtocart'><a class='button alt' href='".$cartUrl."'>".__('Edit Cart','wooint')."</a></p>";
echo $backToCartLink;
}
Well, if you created a child theme you could have put that line in your child's functions.php and then the only way an update would affect it is if they changed the coding.