2017-05-02 3 views
0

임 정확하게 일을하려고 이동하는 작업을 추가/제거, 최신 릴리스 중 하나이 변경되었습니다 :Woocommerce 포인트 및 보상이 - 제목이 말하는 것처럼 render_product_message

public function __construct() { 

    // add single product message immediately after product excerpt 
    add_action('woocommerce_single_product_summary', array($this, 'render_product_message')); 

    // add variation message before the price is displayed 
    add_action('woocommerce_single_product_summary', array($this, 'add_variation_message_to_product_summary'), 15); 

    // add the points message just before the variation price. 
    add_filter('woocommerce_variation_price_html', array($this, 'render_variation_message'), 10, 2); 
    add_filter('woocommerce_variation_sale_price_html', array($this, 'render_variation_message'), 10, 2); 

    // Check for same price but variable points 
    add_filter('woocommerce_available_variation', array($this, 'check_for_variable_points_in_product')); 

    // delete transients 
    add_action('woocommerce_delete_product_transients', array($this, 'delete_transients')); 
} 

이에 :

public function __construct() { 

    // add single product message immediately after product excerpt 
    add_action('woocommerce_before_add_to_cart_button', array($this, 'render_product_message'), 15); 

    // add variation message before the price is displayed 
    add_action('woocommerce_before_add_to_cart_button', array($this, 'add_variation_message_to_product_summary'), 25); 

    // add the points message just before the variation price. 
    add_filter('woocommerce_variation_price_html', array($this, 'render_variation_message'), 10, 2); 
    add_filter('woocommerce_variation_sale_price_html', array($this, 'render_variation_message'), 10, 2); 

    add_filter('woocommerce_show_variation_price', '__return_true'); 

    // delete transients 
    add_action('woocommerce_delete_product_transients', array($this, 'delete_transients')); 
} 

나는 첫 번째로 add_actions의 첫 번째 주소를 제거하려고 시도하고 원래 위치로 다시 삽입하려고합니다.

는 성가 시게 필자 읽을 수 있었던 것과 그래서 이것에 대해 그물에 작은 문서를,이 및 플러그인 코어/템플릿 파일은에 붙여 필자 무엇을하는이 중 하나 명에 대한 언급이있다.

내 코드 아무튼 작동하지 않고, 직접이 함수를 them.php에 추가했고 행운을 빌어 여러 변형을 시도했습니다. 다음은 당신을 위해 작업을 추가 한 클래스의 인스턴스에 액세스 할 필요가 ... 필자가 지금까지 가지고 올 것입니다

1.

remove_action('woocommerce_before_add_to_cart_button', array($this, 'render_product_message'), 15); 
    remove_action('woocommerce_before_add_to_cart_button', array($this, 'add_variation_message_to_product_summary'), 25); 

2.

remove_action('woocommerce_before_add_to_cart_button', 'render_product_message', 15); 
remove_action('woocommerce_before_add_to_cart_button', 'add_variation_message_to_product_summary', 25); 

답변

0

그것을 제거하십시오. 문서에서

예 2 : https://codex.wordpress.org/Function_Reference/remove_action#Example

$this 클래스의 외부에서 작동하지 않습니다.

실용적인 방법이 있는지 알아보기 위해 클래스가 어떻게 인스턴스화되는지 살펴 봐야합니다. 인스턴스를 전역 변수로 설정하거나 singleton pattern을 사용하는 것과 같은 것을 찾고 있습니다.