Maybe this is already answered somewhere else, but I couldn't find it after researching for 5 days.
I've a custom WP Query that returns products for JavaScript AJAX client. My client wants to handle the "number of rows" and "columns" through wooCommerce config that is available through customization of shop page.
Here's my basic implementation for custom WP Query:
function loadProducts(){
// Access the number of rows and columns input here from customization page??
}
add_action("wp_ajax_loadprods","loadProducts");
add_action("wp_ajax_nopriv_loadprods","loadProducts")
CodePudding user response:
From the ref: /wp-content/plugins/woocommerce/includes/wc-template-functions.php
function loadProducts(){
$columns = get_option('woocommerce_catalog_columns', 4);
$rows = absint(get_option('woocommerce_catalog_rows', 4));
echo json_encode(array('columns' => $columns, 'rows' => $rows));
wp_die();
}
add_action("wp_ajax_loadprods","loadProducts");
add_action("wp_ajax_nopriv_loadprods","loadProducts")