Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Jeff Alvarez

    (@superlemon1998)

    Hi @grigoriadis24 ,

    Yes, it should be possible to add rules and filter to custom fields but I’m not entirely sure on how it’s set up on your end so it might not be possible.

    In most cases if you use ACF you can use the rules and filter for it.

    Thread Starter grigoriadis24

    (@grigoriadis24)

    Hello there and thank you for your respond.. No, I am not using an entire plugin for that.. I have just added a custom function in function.php file, thus I have the custom field inside variables.. But, I can not select this custom field in your filters and rules dropdown list you have in your plugin. If it helps, I use this code:

    // Display custom field to variation
    add_action( ‘woocommerce_variation_options_pricing’, ‘show_custom_field_in_variations’, 10, 3 );
    function show_custom_field_in_variations( $loop, $variation_data, $variation ) {
    woocommerce_wp_text_input( array(
    ‘id’ => ‘exclude_variation_skroutz_’ . $variation->ID,
    ‘label’ => __( ‘Exclude Variations from Skroutz’, ‘woocommerce’ ),
    ‘desc_tip’ => ‘true’,
    ‘description’ => __( ‘Enter 1 to exclude, otherwise 0’, ‘woocommerce’ ),
    ‘value’ => get_post_meta( $variation->ID, ‘_exclude_variation_skroutz’, true )
    ) );
    }

    // save custom field to DB
    add_action( ‘woocommerce_save_product_variation’, ‘save_custom_field_variations’, 10, 2 );
    function save_custom_field_variations( $variation_id, $i ) {
    $custom_field = $_POST[‘exclude_variation_skroutz_’ . $variation_id];
    if ( isset( $custom_field ) ) {
    update_post_meta( $variation_id, ‘_exclude_variation_skroutz’, esc_attr( $custom_field ) );
    }
    }

    Thus, I have a field with a value of 1 or 0.. If the value is 1 I want to exclude this variation from the XML I generate.. What should I do to find this custom field in your plugin? I also have this code:

    add_filter(‘wf_feed_product_custom_fields’, ‘add_custom_fields_to_feed’, 10, 1);
    function add_custom_fields_to_feed($custom_fields) {
    $custom_fields[] = ‘exclude_variation_skroutz’;
    return $custom_fields;
    }

    but did not work! thank you for your time, please advice me!

    Plugin Support Jeff Alvarez

    (@superlemon1998)

    Hi @grigoriadis24,

    Sorry but I’m afraid we aren’t able to help here as it’s outside our support scope.

    Thread Starter grigoriadis24

    (@grigoriadis24)

    Thank you for your time, I could find a solution with variations of my products. I let you know if need anything else.. thanks again!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Filter Custom field in variation’ is closed to new replies.