Skip to content
Advertisement

Add custom settings to WooCommerce Products tab

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.

Thanks.

Advertisement

Answer

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);
                       array_push($modified_settings,$page_id);                       

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

add_filter('woocommerce_product_settings', 'add_outlet_page_setting');
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement