remove_action hook not working to remove credit card fields from donation form GiveWP - wordpress

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
}

Related

how to remove "added-to-cart notice" from every page except product archive pages?

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.

How to add Stripe ApplePay to woocommerce minicart

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.

WooCommerce, WP 4.9.7 update product attribute after order

I have a product what have attribute limited-edition-counter. When someone will buy this product I need to increment this attribute.
I tried to use add_action( 'woocommerce_order_status_completed', _my_function, 10, 1);
but it isn't called after order. It's only one trigger what I found to call after each order.
I use own plugin to extends WP.
Any hints how can I solve this problem?
Thanks in advance.
you can use woocommerce_thankyou hook so it will call everytime when someone order from the store.
add_action( 'woocommerce_thankyou', 'your_function' );
function your_function()
{
//access `limited-edition-counter` attribute here and increment it here
}

Wordpress remove_meta_box issue

I run into a problem trying to get remove_meta_box() to work
/** remove metabox for catchkathmandu options
*/
function vpm_remove_meta_box() {
remove_meta_box( 'catchkathmandu-options', 'post', 'normal' );
remove_meta_box( 'authordiv' , 'page' , 'normal' ); //removes author
}
add_action( 'add_meta_boxes', 'vpm_remove_meta_box' );
The point is I dont want contributors and authors to edit the site design, so I wanted to remove the catchkathmandu-options. the code obviously does not reflect the condition, the codex for this function supplies the solutions for that but this code at the besic step, still isnt working - I switched back to Twenty Sixteen theme and put in the authordiv section simply to test. But still no dice.
It's added to child theme functions.php
Have I taken the wrong path and am I looking at the wrong thing entirely?
Any help appreciated!
I suppose that you are using a theme called "Catch katHmandu", and you want to remove a meta box for everyone except Admins.
Here is the usage of remove meta box:
remove_meta_box( $id, $page, $context );
And the Reference on the codex: https://codex.wordpress.org/Function_Reference/remove_meta_box
As you can read on the codex, $id is the current id of the div that you want to remove. Let's say that you want to remove "Tags box", if look for its container id you will find:
<div id="tagsdiv-post_tag" class="postbox">
...
</div>
And if you want to remove tags meta box, your code will look like this:
if (!is_admin()) :
function my_remove_meta_boxes() {
remove_meta_box('tagsdiv-post_tag', 'page', 'normal');
}
add_action( 'admin_menu', 'my_remove_meta_boxes' );
endif;
Look for the id of the meta box that you want to remove and remplace "tagdiv-post_tag" from code above with your id.
If you like my answer click the top arrow, as a coder it would mean a lot for me. Thanks!
EDIT:
As #AndrewSeabrook say, try using admin_menu hook instead of add_meta_boxes in your function.

Woocommerce - How to remove the Add to Cart Button on product listing

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/

Resources