L
L
ligisayan2015-12-23 17:35:42
WordPress
ligisayan, 2015-12-23 17:35:42

How do I swap blocks on a wordpress product page?

Greetings! I have a store on wordpress + woocommerce, which has 2 blocks: the block with a discount (own function in functions.php) is displayed on the product page using a hook in this way

add_action('woocommerce_single_product_summary', 'woocommerce_template_economy', 13);

and the discount lifetime counter (implemented using the woo sale revolution flashsale plugin)
is displayed using filters in the following form:
class WC_flash_sale_Product {
  public function __construct()
  {
      add_filter( 'woocommerce_grouped_price_html', array(&$this, 'on_price_htmla'), 10, 2 );
      add_filter( 'woocommerce_variable_price_html', array(&$this, 'on_price_htmla'), 10, 2 );
      add_filter( 'woocommerce_sale_price_html', array(&$this, 'on_price_htmla'), 10, 2 );
      add_filter( 'woocommerce_price_html', array(&$this, 'on_price_htmla'), 10, 2 );
      add_filter( 'woocommerce_empty_price_html', array(&$this, 'on_price_htmla'), 10, 2 );
      add_filter( 'woocommerce_variation_price_html', array(&$this, 'on_price_htmla'), 10, 2 );
      add_filter( 'woocommerce_variation_sale_price_html', array(&$this, 'on_price_htmla'), 10, 2 );
      add_filter( 'woocommerce_variable_sale_price_html', array(&$this, 'on_price_htmla'), 10, 2 );
  }
}
new WC_flash_sale_Product();

I’m trying to swap blocks (with the plugin comes first), set priorities, but it
does n’t
7da094035b0b40b58218540903a59e7f.png
work .
28b121b275444afea8e4cde821565ab8.png
efaf6c09a2884e36ba5059693af56c72.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WP Panda, 2015-12-23
@wppanda5

Nothing is clear.
woocommerce_single_product_summary - displays everything about the product, the following actions are hung on it,

add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );

respectively, to replace them in places, it is enough to do
//отключить функцию от экшена с текущим приоритетом
remove_action('action','function',priory)
// подключить с неообходимым
add_action('action','function',priory)

filters from the class constructor are for changing the price html code and do not affect the location of the blocks in any way

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question