I was able to hide Apple Pay button from single product page following way
// in functions.php
add_filter( 'wc_stripe_hide_payment_request_on_product_page', '__return_true' );
but now I want to add this button to minicart. Is there any hook or shortcode that allows placing Apple Pay button on minicart?
I am using this plugin https://wordpress.org/plugins/woocommerce-gateway-stripe/
add_action( 'woocommerce_widget_shopping_cart_buttons', 'mini_cart_stripe_button', 20 );
function mini_cart_stripe_button() {
if( wp_is_mobile() ){
//I'd like to add button here
}
}
Not sure if this helps but the snippet below makes the button appear on checkout.
add_filter( 'wc_stripe_show_payment_request_on_checkout', '__return_true' );
Also, here are some of the ApplyPay elements:
#wc-stripe-payment-request-wrapper
#wc-stripe-payment-request-button
#wc-stripe-payment-request-button-separator
Please let me know if you figure this one out. I would love to add this to the mini cart as well! Cheers.
Related
I've made a back link to take customer from single product back to product display. I need to know how to give this code a class to make it a button.
The code is
add_action( 'woocommerce_after_add_to_cart_button', 'back_button', 10 );
function back_button() {
global $product;
echo ' Go Back to selection ';
Thanks
I tried putting
add_action( 'woocommerce_after_add_to_cart_button', 'back_button', 10 );
function back_button() {
global $product;
echo ' <button>Go Back to selection</button> ';
}
In answer to my own question, even though it's not really what I was after but it does the job. I got Wordpress Back button widget plugin. It lets you add “Back” button to your website.
The button can be added via widget, [alg_back_button] shortcode or echo alg_back_button( 'Back' ); function. So until I learn more, this will do. I hope this will help someone else :)
Note: In looking for an answer to my question I came across this post but it is NOT duplicate: Remove add to cart notice and change "add to cart" button in Woocommerce the answer there gives the option to remove the notice from the entire site. I want to remove it only from the cart page and I don't want to do it with CSS.
I use external links to my site to send people directly to the shopping cart with the item already added to the cart. When doing so, the "added-to-cart notification" shows up on the cart page which I do not want.
I found this code which removes the added-to-cart notification: add_filter( 'wc_add_to_cart_message_html', '__return_false' ); but it removes the notification from all pages of my site which is not what I want.
To be more specific, I want the added-to-cart notification to show on every product archive page and nowhere else.
I tried to add a filter but it doesn't work the way I would expect it to, I tried the following two ways (and tested it with various pages to see if I could make anything work but it seems my general syntax is off because I Can't get it to do anything...
function hide_cart_notes() {
if ( ! is_archive() ) {
add_filter( 'wc_add_to_cart_message_html', '__return_false' );
}
}
add_action( 'woocommerce', 'hide_cart_notes' );
function hide_cart_notes() {
if ( is_archive() ) {
return;
}
add_filter( 'wc_add_to_cart_message_html', '__return_false' );
}
add_action( 'woocommerce', 'hide_cart_notes' );
when woocommerce hook starts? where it's docs? does it run at all?
these question should be answered before.
i know that WordPress parses query at parse_query hook, so i would try this
add_action('parse_query', function() {
if (!is_archive()) {
add_filter( 'wc_add_to_cart_message_html', '__return_false' );
}
});
because is_shop(), is_archive(), is_* need query to be parsed first.
I have used below action hook to hide fields but it is not working.
remove_action( 'give_cc_form', 'give_get_cc_form' );
can anyone help me to figure out this issue
I am using GiveWP plugin for donation in WordPress site.
GiveWP has a pretty expansive snippet library, and one example shows how you can remove and rearrange fields. This is probably the best place to start from:
https://github.com/impress-org/givewp-snippet-library/blob/master/form-customizations/customize-fieldset-order.php
function give_remove_fieldsets() {
remove_action( 'give_cc_form', 'give_get_cc_form' );
}
add_action( 'init', 'give_remove_fieldsets' );
this actually worked for me
Make sure to run it at init, and you need to add the same priority used in the add_action, if none it uses 10 and the priority can be left blank
add_action('init','remove_actions');
function remove_actions() {
remove_action( 'give_cc_form', 'give_get_cc_form', 1 ); // Replace the priority with the correct one
}
I need to hide my add to cart button on the condition where the price = 0.00. If the price is greater than 0.00 i would like the button to reappear.
However i also use the WooTheme Wish List extension and i need the add to wish list button to remain. I would also like to change the text from Free to "Subscription Product" when the value is 0.00.
This is only needed on the single product page as we do not show the add to cart anywhere else.
Currently if the price is set to 0.00 i get the text at the top of the single product page saying "free" and the add to cart button remains as does the add to wish list button. If i remove the price all together the buttons also disappear hence why i need to "hide" the button to retain the wish list one.
I have tried the following Code inserted into my functions.php file
<?php
/*
* Swop the 'Free!' price notice and hide the cart with 'POA' in WooCommerce
*/
add_filter( 'woocommerce_variable_free_price_html', 'hide_free_price_notice' );
add_filter( 'woocommerce_free_price_html', 'hide_free_price_notice' );
add_filter( 'woocommerce_variation_free_price_html', 'hide_free_price_notice' );
function hide_free_price_notice( $price ) {
remove_action ( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
return 'POA';
}
?>
However, although it did work in that it changed the "Free" text to "POA" and also hid the "Add to Cart button" the "Add to Wishlist" button also disappeared.
If i changed the value to 0.01 everything appeared again so it nearly there... i just need the Wish List button to stay.
Any help or pointers would be greatly appreciated. Many Thanks...
Just for info, the reason i need to do this is because we run a subscription service, so products that are included in a subscription service do not need a price but do need to be shown so they can be added to a wish list. However sometimes we sell the products off so when they have a value i need the button to reappear so they can be added to the cart.
Simply having zero doesn't work because believe it or not people think they are free and try to add them to the cart to purchase !
Please add below code in your active theme functions.php and check it.
function wpcustom_is_purchasable( $purchasable, $product ){
if( $product->get_price() == 0 )
$purchasable = false;
return $purchasable;
}
add_filter( 'woocommerce_is_purchasable', 'wpcustom_is_purchasable', 10, 2 );
I'm wanting to remove the Add to Cart Button on the product listing pages. The only place I want it to appear is the individual product page. Can anyone suggest on where I can find to remove this? I haven't been able to get any help from the documentation.
At the moment the button appears under every listing.
I don't know how to do it from WooCommerce but with following code it is possible, just make sure that these PHP code should execute, so, put it at suitable place in PHP file where some PHP codes are executing, best place would be any wordpress plugin's base file, be careful while updating that plugin as these code will get lost after updating.
add_action( 'woocommerce_after_shop_loop_item', 'remove_add_to_cart_buttons', 1 );
function remove_add_to_cart_buttons() {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
}
We have found the answer by coding a little bit, in wordpress:
function remove_loop_button(){
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
}
add_action('init','remove_loop_button');
here: https://www.igniweb.com/remove-add-to-cart-button-wordpress/
You can remove the add to cart button from product pages by adding this in woocommerce.php (located wp-content/plugins/woocommerce)
function Wp() {
remove_action( 'woocommerce_after_shop_loop_item',
'woocommerce_template_loop_add_to_cart');
remove_action( 'woocommerce_single_product_summary',
'woocommerce_template_single_add_to_cart');
return WooCommerce::instance();
}
After adding this code, reload the page and you will see that the button has been hidden.
You can also remove the add to cart button from specific Product pages using this code in functions.php (located in the theme folder):
add_filter('woocommerce_is_purchasable', 'wp_specific_product');
function wp_specific_product($purchaseable_product_wp, $product)
{
return ($product->id == specific_product_id (512) ? false :
$purchaseable_product_wp);
}
For reference you can see
https://wpitech.com/hide-disable-add-to-cart-button-in-woocommerce-store/