Поддержка WooCommerce Нужна помощь, чтобы поменять местами цены

  • Есть товар, в нем, при помощи плагина Unit of measure добавлен текст после цены. Можно ли этот текст сделать перед ценой товара, а не после?

    Сам код этого плагина:
    ———————————-

    <?php
    if ( ! defined( 'ABSPATH' ) ) :
    	exit; // Exit if accessed directly
    endif;
    
    class Woo_Uom_Output {
    
      /**
       * The Constructor!
       * @since 1.0.1
       */
      public function __construct() {
        $this->uom_add_actions_filters();
      }
    
      /**
       * Add actions and filters.
       * @since 1.0.1
       */
      function uom_add_actions_filters() {
        add_filter( 'woocommerce_get_price_html', array( $this, 'woo_uom_render_output' ), 10, 2 );
      }
    
    	/**
    	 * Render the output
    	 * @since 1.0.1
    	 * @return $price + UOM string
    	 */
    	 function woo_uom_render_output( $price ) {
    	  global $post;
    	  // Check if uom text exists
    	  $woo_uom_output = get_post_meta( $post->ID, '_woo_uom_input', true );
    	  // Check if variable OR UOM text exists
    	  if ( $woo_uom_output ) :
    			$woo_uom_price_string = $price  . ' ' . '<span class="tab-content-inner">' . esc_attr_x( $woo_uom_output, 'woocommerce-uom' ) . '</span>';
    			return $woo_uom_price_string;
    	  else :
    			return $price;
    	  endif;
    	}
    
    }
    // Instantiate the class
    $woo_uom_output = new Woo_Uom_Output();
    • Тема изменена 5 лет назад пользователем Denis Yanchevskiy. Причина: Оформление кода

    Страница, с которой нужна помощь: [войдите, чтобы увидеть ссылку]

Просмотр 2 ответов — с 1 по 2 (всего 2)
  • Обратите внимание на эту строку кода:
    $woo_uom_price_string = $price . ' ' . '<span class="tab-content-inner">' . esc_attr_x( $woo_uom_output, 'woocommerce-uom' ) . '</span>';

    вначале, выводится Цена, затем Текст.
    Просто, поменяйте их местами.

    на этой странице после цены идет краткое описание.
    Вы его хотите передвинуть выше цены?

Просмотр 2 ответов — с 1 по 2 (всего 2)
  • Тема «Нужна помощь, чтобы поменять местами цены» закрыта для новых ответов.