Woocommerce checkout payment method hook - woocommerce

How to change the hook of the payment method in checkout page?
I found an actions that return order review form with payment method, but how to divide them? One action order review and one payment method
do_action( 'woocommerce_checkout_order_review' );

Two different actions are hooked into 'woocommerce_checkout_order_review'. Those are 'woocommerce_order_review' for order review and 'woocommerce_checkout_payment' for payment method.
This is defined in "includes/wc-template-hooks.php"
add_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
add_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 );
Action hook 'woocommerce_order_review', calls template page "checkout/review-order.php".
Action hook 'woocommerce_checkout_payment', calls template page "checkout/payment.php"
Above two action/hook functions are defined in "includes/wc-template-functions.php"
Hope this helps.

Related

Change the paypal item name in the PayPal Express Checkout plugin

I have a WordPress site using the PayPal Checkout plugin for woocommerce.
https://wordpress.org/plugins/woocommerce-gateway-paypal-express-checkout/
I need to change the PayPal item name and I'm using this code in the functions.php, it worked with the normal PayPal plugin but does not work with PayPal Express checkout.
add_filter( 'woocommerce_paypal_get_order_item_name', 'change_paypal_item_name', 10, 3 );
function change_paypal_item_name( $item_name, $order, $item ) {
return 'test';
}
Anyone know the function to change the item name with the PayPal Express checkout plugin?
From a quick look at the code, it seems woocommerce_paypal_express_checkout_get_details is a filter you can try implementing to modify the whole $details array

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
}

Using add_action hook of GravityForms add-on stickylist

GravityForms has a simple action hook that can be used after submission
add_action( 'gform_after_submission', 'my_function', 10, 2 );
my_function is any user-defined function where the call reaches if the action hook is found in functions.php
StickyList, an add-on built on GravityForms also provides an action hook that can be used after the form is submitted. It is here below
add_action("gform_after_submission", array($this, "post_edit_entry"),
10, 2);
My question is, how does one use the my_function to the StickyList action hook which hasn't specified/documented how to use this action hook. I don't know what the array is doing as a second argument and how to get the call to reach my user defined function once this action_hook is found in functions.php.
The stickyList add_action hook after editing entry I found that worked was the following. Thanks Samvel for your help.
add_action('stickylist_entry_edited','my_function', 10, 2 );

how to prevent woocommerce saving user untill they pay?

I am using woocommerce subscription. It is saving user and makes them logged on once they finish checkout form. How to make like they do not get saved / logged-in until payment success?
You could hook into the woocommerce_thankyou hook and logout the current user there. But that is a little late. Better would be the user to be logget out before the page is displayed, not after.
add_action( 'woocommerce_thankyou', 'my_custom_logout_function_here', 10 );
function my_custom_logout_function_here( $orderid ) {
echo 'Your message here';
wp_logout();
}

display custom fields automatically when a custom post type is displayed

I am trying to automatically display all the custom fields of a custom post type alongside it's title and content.(Not in admin but on my actual site)
I need to be able to do this with an action hook or filter, rather than creating a template.
After scouring the web I was able to find the 'publish_{custom_post_type_name}' hook:
function my_cool_hook() {
echo get_post_meta($post->ID, 'my-custom-field-name', true);
}
add_action( 'publish_past_symposia', 'my_cool_hook' );
but it doesn't seem to do anything when I view my published custom post type on my site. Any ideas?
add_action( 'publish_past_symposia', 'my_cool_hook' );
This hook triggered only if PUBLISH post type.
YOu need to trigger the hook on web part - so...
add_filter('the_content', 'my_cool_hook');
function my_cool_hook($content){
return $content.get_post_meta(get_the_id(), 'my-custom-field-name', true);
}
now the content body filtred and your string from custom fields added.

Resources