Skip Navigation

[Resolved] probleme taxonomy

This support ticket is created 6 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 0.00 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 5 replies, has 2 voices.

Last updated by cherifM 5 years, 12 months ago.

Assisted by: Minesh.

Author
Posts
#1158169
Capture d’écran 2018-12-03 à 23.00.23.png

Hello,
the value of the taxonomy terms are empty After form submit.
Thanks a lot for the help!

$value=$_POST["pa_condition"];
$taxonomies = get_taxonomies();
foreach ( $taxonomies as $tax_type_key => $taxonomy ) {
if ( $term_object = get_term_by( 'slug', $value , $taxonomy ) ) {
break;
}
}
$term_id = htmlspecialchars( stripslashes( $term_object->taxonomy) );
$term_taxonomy_ids =wp_set_object_terms( $post_id, $value, '_product_attributes' ,true);
$product_attributes= array (
'name' => $term_id, // set attribute name
'value' => $value, // set attribute value
'position' => 1,
'is_visible' => 1,
'is_variation' => 1,
'is_taxonomy' => 1
);

if(count($product_attributes) > 0)
{
update_post_meta($post_id, '_product_attributes', $product_attributes);
}

#1158527

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - Toolset Forms do not support product attributes for now (You can add to forms but attribues will not get saved to database). You can see its already mentioned with our Docs:
=> https://toolset.com/documentation/user-guides/creating-woocommerce-products-using-cred-forms/#which-product-fields-you-can-use-in-toolset-forms

if you want to publish products and set product attributes this needs custom code. The following link may help you:
=> hidden link

#1158545

Hi Minesh,

Yes I want to publish products and set product attributes but ATTRIBUTE_VALUE
he save an empty value (screenshot)

add_action( 'dokan_product_updated', 'x_add_fields_save' ,10, 2);

function x_add_fields_save( $post_id ){
$term_id = htmlspecialchars( stripslashes( $taxonomy) );
$term_taxonomy_ids =wp_set_object_terms( $post_id, $value, '_product_attributes' ,true);
$product_attributes= array (
'name' => $term_id, // set attribute name
'value' => $value, // set attribute value
'position' => 1,
'is_visible' => 1,
'is_variation' => 1,
'is_taxonomy' => 1
);

if(count($product_attributes) > 0)
{
update_post_meta($post_id, '_product_attributes', $product_attributes);
}
}

#1158546

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - as I already informed you that this is a custom code which is eventually beyond the scope of our support policy as Toolset does not offer this feature natively.

If custom programming is something you are comfortable doing you may ask the help of a developer who is able to write PHP using the Forms API. I suggest for our any custom programming need, please feel free to contact our certified partners:
=> https://toolset.com/contractors/

#1158550

I found the solution Thank you.

term_taxonomy_ids =wp_set_object_terms( $post_id, $value, $term_id ,true);

$product_attributes[$i] = array (
'name' => $term_id, // set attribute name
'value' => $value, //
'position' => 1,
'is_visible' => 1,
'is_variation' => 1,
'is_taxonomy' => 1
);

#1158551

My issue is resolved now. Thank you!