If you want to modify the PDF category or products layout for different categories you can use the following 2 filter:

  • woocommerce_pdf_catalog_category_layout
  • woocommerce_pdf_catalog_products_layout

Example how to modify the category layout:

function modify_pdf_category_layout( $layout, $category_id) {

	if($category_id == 18) {
		$layout = 2;
	}

    return $layout;
}
add_filter( 'woocommerce_pdf_catalog_category_layout', 'modify_pdf_category_layout', 10, 2 );

Example how to modify the products layout and do not touch the Full catalog layout:

function modify_pdf_products_layout( $layout, $category_id) {

	// Do not modify product layouts for full catalog
	if($_GET == "full") {
		return $layout;
	}

	// Change the product layout for category 18 (clothing) to Layout 2
	if($category_id == 18) {
		$layout = 1;
	}

	// Hoodies
	if($category_id == 19) {
		$layout = 2;
	}

    return $layout;
}
add_filter( 'woocommerce_pdf_catalog_products_layout', 'modify_pdf_products_layout', 10, 2 );

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *