Add custom settings to WooCommerce Products tab

Rate this post

I’m using WordPress and WooCommerce for my e-commerce. I need to duplicate the “Shop Page” option (under WooCommerce > Settings > Products > General), creating a new option “Outlet Page” after the first, which the user can populate late with the desired page. How can I do that? I’m searched but nothing seems to fit my problem.




I’ve found a solution using the woocommerce_product_settings default filter.

function add_outlet_page_setting($settings)
  $page_id = array(
    'title'    => __('Pagina Outlet', 'wc_outlet_page'),
    'id'       => 'woocommerce_outlet_page_id',
    'type'     => 'single_select_page',
    'default'  => '',
    'class'    => 'wc-enhanced-select-nostd',
    'css'      => 'min-width: 300px;',
    'desc' => 'La pagina raccoglie tutti i prodotti attualmente in sconto.',
    'desc_tip' => __('Questo imposta la pagina di outlet del tuo negozio - qua è dove si troverà il vostro archivio dei prodotti in saldo.', 'wc_outlet_page')

  $modified_settings = array_slice($settings, 0, 2, true);

  return array_merge($modified_settings, array_slice($settings, 2, count($settings), true));

add_filter('woocommerce_product_settings', 'add_outlet_page_setting');

Leave a Reply

Your email address will not be published.

Back to top button