php - Adding back removed action, based on custom meta data wordpress -


What am I trying to do?

  1. A custom URL input from the user, it Save Products as Meta
  2. If any such URL set is not empty, remove the add_to_cart button with the custom link and the place in the button.
  3. If not, then it would have been used to add a fall-back add to cart button and in one form

    How to find the code here Used to be -.

      ADD_ACTION ('init', array ($ this, 'woocommerce_custom_add_to_cart_remove_add_to_cart')); // goes Series creator function woocommerce_custom_add_to_cart_remove_add_to_cart () {remove_action ( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30); Remove_action ('woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30); Remove_action ('woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart', 30); Remove_action ('woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30); Remove_action ('woocommerce_external_add_to_cart', 'woocommerce_external_add_to_cart', 30); Add_action ('woocommerce_single_product_summary', array ($ this, 'woocommerce_custom_add_to_cart_custom_button'), 30); Add_action ('woocommerce_simple_add_to_cart', array ($ this, 'woocommerce_custom_add_to_cart_custom_button'), 30); Add_action ('woocommerce_grouped_add_to_cart', array ($ this, 'woocommerce_custom_add_to_cart_custom_button'), 30); Add_action ('woocommerce_variable_add_to_cart', array ($ this, 'woocommerce_custom_add_to_cart_custom_button'), 30); Add_action ('woocommerce_external_add_to_cart', array ($ this, 'woocommerce_custom_add_to_cart_custom_button'), 30); } Function woocommerce_custom_add_to_cart_custom_button () {global $ post, $ product; If ($ this-> woocommerce_custom_add_to_cart_get_cartURL)! = '') echo '& lt; form name = "custom_cart_button" method = "post" action = " '. $ this- & gt; woocommerce_custom_add_to_cart_get_cartURL ().' '& gt; & lt; button type =" submit "class =" Single_add_to_cart_button button alt "& gt ; '$ This- & gt; woocommerce_custom_add_to_cart_get_carttext ().' & Lt; / button & gt; & lt; / form & gt; & lt; br / & gt; '; else {// what should be here to handle back down, and add the Show default add tasks to cart button Do not work}}    

    where will get another hook to remove_action and Try carrying ADD_ACTION code product ID as "woocommerce_before_single_product_summary" and if it matches the default woocommerce to remove the hook and add your hook inside th Check the status,

    hooks is not far. "Woocommerce_single_product_summary - & gt; woocommerce_template_single_add_to_cart " is not required because the add it back.

      add_action (" woocommerce_before_single_product_summary "," test_func "); function test_func () {global $ post, $ product; if (Test Condition) {remove_action ( 'woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30); Remove_action ( 'woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart', 30); Remove_action ( 'woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30); Remove_action ( 'woocommerce_external_add_to_cart', 'Woocommerce_external_add_to_cart', 30); Add_action ('woocommerce_simple_add_to_cart', 'woocommerce_custom_add_to_cart_custom_button', 30); Add_action ('woocommerce_grouped_add_to_cart', 'woocommerce_custom_add_to_cart_custom_button', 30); Add_action ('wooco Mmeri_veriabl_aed_to_cart 'Wookmers_kstm_aed_to_cart_kstm_btn', 30); USER_ROLE ( 'Wookmers_akstrnl_aed_to_cart' Wookmers_kstm_aed_to_cart_kstm_btn ', 30); }} Function woocommerce_custom_add_to_cart_custom_button () {global $ post, $ product; Look & lt; Form name = "custom_cart_button" method = "post" action = "REQUIRED_URL" & gt; Button type = "submit" class = "single_add_to_cart_button button alt" & gt; Button text & lt; / Button & gt; & Lt; / Form & gt; & Lt; Br / & gt; '; }    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -