Query Product categories what have a custom field

Im trying to build a page template on wordpress that will show a list a categories that have a custom field checked.

So the taxonomy is just the default woocommerce taxonomy product_cat I then have a custom field to the product_cat taxonomy which is a check box called collectable

My set up is
Main Category

  • Child
  • Child
  • Child
  • Child

So for example 2 children categories have the tick box collectable which is set to add the value of 1 into the datbase

So I am doing a page where it will show all categories with the collectable checked.

$args = array(
    'post-type' => 'product',
    'taxonomy' => 'product_cat',
    'hide_empty' => 0
  $c = get_categories($args);
  $c_keep = array();
  foreach($c as  $cat){
 if (get_field('collectable', 'category_'.$cat->term_id)) {
      $c_keep[] = $cat;
  foreach($c_keep as $cat){
    echo $cat->name;

But I am getting nothing at all returned.

I even put a

print_r( $args );

But I am still coming up with a blank (Header and footer Loads and the text above the query)

Can anyone help please

Go to Source
Author: user1348927

Gravity Forms for Woocommerce Add-on – GF Products amount not calculated in cart

Has anyone had experience with the Gravity Forms for Woocommerce Add-on? Specifically when generating GF Product fields.

Here is what I am trying to accomplish:
Using a Woocommerce product, I’ve added ACF fields, so that my client can add/edit/disable menu items for a Build Your Own BBQ.

enter image description here

I use a gravity form and its filters to generate these menu items as GF products based on the ACF field values.

enter image description here

Using the Gravity Forms for Woocommerce Add-on, I use the Gravity Form with the Woocommerce product, so that it can be added to the cart and checkout.

enter image description here

When setting quantities, the product calculation is correctly totaled.

enter image description here

When added to cart, is where the issue is. The cart shows as $0.00, while the “product” is correct.

enter image description here

GF product fields work fine when added directly through the Gravity Forms wordpress UI. But I need to generate them via code. The Add-on developer has said that in theory it should work when done this way, but was not sure. Has anyone tried this before?

Here is the code I wrote to generate the GF Products (menu items):

add_filter( 'gform_pre_render_10', 'backyard_smokeout_products' );
add_filter( 'gform_pre_validation_10', 'backyard_smokeout_products' );
add_filter( 'gform_admin_pre_render_10', 'backyard_smokeout_products' );
add_filter( 'gform_pre_submission_filter_10', 'backyard_smokeout_products' );
function backyard_smokeout_products($form) {
    $counter = array();
    $new_fields = array();

    foreach ($form['fields'] as $field) {
        $counter[] = is_int($field->id) ? $field->id : 0;

    $counter = max($counter) + 1;

    $section = array (
        'id' => $counter,
        'type'  => 'section',
        'label' => 'Add Sides to your Custom BBQ',
        'description'   => '(a minimum quantity of 4 is required for any item you order)',
    $field = GF_Fields::create($section);
    array_push($new_fields, $field);

    $sides = get_field('backyard_sides', 1122);

    if($sides) {
        foreach ($sides as $side) {
            if($side['side_enable'] == true) {
                $props = array (
                    'id' => $counter,
                    'label' => $side['side_name'],
                    'type'  => 'product',
                    'inputs' => array(
                          'id'    => $counter.'.1',
                          'label' => 'Product Name',
                          'name'  => $side['side_name'],
                          'id'    => $counter.'.2',
                          'label' => 'Price',
                          'name'  => $side['side_price'],
                          'id'    => $counter.'.3',
                          'label' => 'Quantity',
                          'name'  => 'param_qty'
                    'basePrice' => $side['side_price'],
                    'inputType' => 'singleproduct',
                    'cssClass'  => 'side-item gf_inline',
                    'description' => $side['side_description'],
                $field = GF_Fields::create( $props );
                array_push($new_fields, $field);

    for ($i=0; $i < count($form['fields']); $i++) { 
        if ('This form is generated programmatically' == $form['fields'][$i]['label']) {
            array_splice( $form['fields'], $i + 1, 0, $new_fields );
            return $form;        
    return $form;

Go to Source
Author: Alexnl

How to use one woocommerce for two websites?

I have website with subdomain. Main website is www.domain.com and second is subdomain.domain.com.
subdomain.domain.com is for shopping site powered by woocommerce. I have linked both website with same users & login. All works great but the problem is there is cart option where cart showing cart details on my subdomain.domain.com site but I want it on my main site (www.domain.com) also. So is there any way to display same value on both website or use single woocommerce installation for two websites.

for ref. I use this (https://themes.oitentaecinco.com/winner/) theme.
Thanks in Advance to help me……….

enter image description here

Go to Source
Author: Mahesh Gadgil

Settings checkbox not triggering function

I have recently created this code as a plugin to store a setting in the WooCommerce general settings. The checkbox is meant to

// Check if WooCommerce is active
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {

    // Settings
    function hm_woo_disable_shop_settings( $settings ) {
        $settings[] = array(
            'title' => __( 'Disable Shop', 'wcds' ),
            'type' => 'title',
            'desc' => 'Check this box to disable all WooCommerce features',
            'id' => 'wcds_settings',

        // Checkbox
        $settings[] = array(
            'title'             => __( 'Disable', 'woocommerce' ),
            'desc'              => __( 'This has no affect to the database and will only limit frontend functions', 'wcds' ),
            'id'                => 'wcds_checkbox',
            'default'           => '',
            'type'              => 'checkbox',
            'desc_tip'          => true,
            'value'             => get_option('wcds_checkbox'),
            'checked'           => esc_attr( checked( 1, get_option('wcds_checkbox'), false ) )

        $settings[] = array( 'type' => 'sectionend', 'id' => 'wcds_settings' );
        return $settings;
    add_filter( 'woocommerce_general_settings','hm_woo_disable_shop_settings', 10, 2 );

    // Functions
    function woocommerce_disable_shop() {
        global $woocommerce;

        // Get the checkbox value from settings
        if( get_option( 'wcds_checkbox' ) === '1' ) {
            add_filter( 'woocommerce_is_purchasable', '__return_false');
    add_action( 'init', 'woocommerce_disable_shop' );

Go to Source
Author: Jesse

Change WooCommerce backend Order_ID

I want to change the Order_ID Prefix on WooCommerce Order because the payment gateway only captures the order ID. As my payment gateway is integrated into three to five websites it is difficult differentiate which payment came from which website.

I have already implemented the Custom Sequential Pro Plugin from WooCommerce but it only changes the order ID on the front end. But the payment gateway collects Order ID from the backend. How can i add a prefix to the order_ID in the backend in WooCommerce.

images: woocommerce: https://pasteboard.co/JiGZcYR.png
Payment Gateway: https://pasteboard.co/JiGZOGY.png

Go to Source
Author: Aetzad Asghar

Make the product page as homepage WooCommerce

I’d like to make the product’s page as homepage. But this product’s page I created with Elementor Pro. I’m trying to use the shortcode [product_page id=99]. But it imports the standard page of theme, not the page I’ve created with Elementor. Someone knows how to do this?

Go to Source
Author: Gabriel Borges

Plugin getting error how to fix


Hello, adding this plugin and getting error on order detail page.

 Fatal error: Uncaught Error: Call to a member function get_billing_state() on null in /home/evelineg/site.ge/wp-content/plugins/woocommerce-city-rate-shipping-master/city-rate-shipping.php:125 Stack trace: #0 /home/evelineg/site.ge/wp-includes/class-wp-hook.php(287): customize_checkout_city_field(Array) #1 /home/evelineg/site.ge/wp-includes/plugin.php(206): WP_Hook->apply_filters(Array, Array) #2 /home/evelineg/site.ge/wp-content/plugins/woocommerce/includes/class-wc-countries.php(737): apply_filters('woocommerce_def...', Array) #3 /home/evelineg/site.ge/wp-content/plugins/woocommerce/includes/class-wc-countries.php(1362): WC_Countries->get_default_address_fields() #4 /home/evelineg/site.ge/wp-content/plugins/woo-checkout-field-editor-pro/classes/class-thwcfd-utils.php(117): WC_Countries->get_address_fields('GE', 'shipping_') #5 /home/evelineg/site.ge/wp-content/plugins/woo-checkout-field-editor-pro/classes/class-thwcfd-settings-general.php(602): THWCFD_Utils::get_fields('shipping in /home/evelineg/site.ge/wp-content/plugins/woocommerce-city-rate-shipping-master/city-rate-shipping.php on line 125

Go to Source
Author: Irakli

Sale price formatting not showing [closed]

WordPress v5.4.2 | WooCommerce v3.7.1 | Theme: Salient v7.0.8

We have variable products with regular and sale prices set, and both prices display on the product page, however the sale price only has standard formatting, there’s no del-tag. So I assume function wc_format_sale_price is not being called. How can I fix this, or what settings should I check please?

function wc_format_sale_price( $regular_price, $sale_price ) {
    $price = '<del>' . ( is_numeric( $regular_price ) ? wc_price( $regular_price ) : $regular_price ) . '</del> <ins>' . ( is_numeric( $sale_price ) ? wc_price( $sale_price ) : $sale_price ) . '</ins>';
    return apply_filters( 'woocommerce_format_sale_price', $price, $regular_price, $sale_price );

Go to Source
Author: Nick W

I want to show either the WooCommerce Price OR the WooCommerce Bookings Price in a Divi module [closed]

I am using WooCommerce combined with WooCommerce Bookings.

We have two types of product, bookable products and nonbookable products. I would like to show the price for the product on the page within a Divi module. We are using Divi to completely style the page of the Divi product so I cannot use an override like I ususally would.

Is there a way to add some PHP code to the functions file then call it as a shortcode in a Divi module?

I tried adding this code to my functions.php within my child theme but when I call it it errors and won’t save the page.


function woo_price_and_bookings_price ($atts)
    global $product;
    $product_id = $product->get_id();
    echo '<h1>The price is: ' . $product->get_price_html() . '</h1>';
add_shortcode( 'price_and_bookings_price', 'woo_price_and_bookings_price' );

shortcode I am calling


The price does not appear, but my text does. However my text appears at the very top of the page and not in the position I have assigned it in Divi. The page also errors on save and seems to automatically open a new page whenever I do this.

The page that opens contains nothing except my code (twice for some reason):

The price is:

What am I doing wrong and is this the right way to approach this task? I need to use Divi as I have inherited the site and we are not using traditional product pages.

Go to Source
Author: Eoin

Woocommerce reports in front-end

I’m trying to create a custom report dashboard in the front-end with a nice chart with the daily sales, but I fail to retrieve the reports

what I tried which its giving me You have an error in your SQL syntax error is

function full_month_report(){
  include_once(WC()->plugin_path(). '/includes/admin/reports/class-wc-report-sales-by-date.php' );
  $sales_by_date = new WC_Report_Sales_By_Date();
  $d = date_i18n('t');
  $d = (int)$d;
  $month_report = array();
  for($i = 1; $i <= $d; $i++){
    $i = sprintf("%02d", $i);
    $date = strtotime(date( 'Ym'.$i ));
    $sales_by_date->start_date = $date;
    $sales_by_date->end_date = $date;
    $day_report = $sales_by_date->get_report_data();
    array_push($day_report, $month_report);
  return $month_report;

What’s the best way to get an object/array with the reports data in front-end?

Go to Source
Author: Razvan Cuceu

Edit tax class in Woocommerce admin order details

I am trying to make select box to change tax class at admin order detail in Woo. I made column, select box with tax classes, when the product is one, it works perfectly. But when i have more than 2 products it gets tax class what have the last of the list (you can see it in video). I would like to be able to set tax class for every item separately… Thanks for help

Here is video

My code in functions.php is like that

function tax_edit_col_h($order){
  <th class="line_changetax">
    Změna daně
add_action( 'woocommerce_admin_order_item_headers', 'tax_edit_col_h' );

function tax_change($item_id, $item, $product) {
    if('line_item' === $item->get_type()){
        <td class="line_changetax" style="width:20%">
            <select name="change_tax" id="change_tax_select" style="width:90%; display:inline-block">
                $arraytax = WC_Tax::get_tax_class_slugs();
                    echo '<option value="'.$item->get_tax_class().'">'.$item->get_tax_class().'</option>';
                foreach($arraytax as $tax){
                    echo '<option value="'.$tax.'">'.$tax.'</option>';
add_action( 'woocommerce_admin_order_item_values', 'tax_change', 10, 3 );

function change_order_item_tax_class( $item ) {
    if (isset($_POST['change_tax']) ) {
add_action( 'woocommerce_before_save_order_item', 'change_order_item_tax_class' ); 

Go to Source
Author: Jirka Kříž