vlasovdmitri
Forum Replies Created
-
Forum: Plugins
In reply to: [WooCommerce] How is an attribute value SLUG created?Oh, and how long did it take me. It turned out that the slug was created incorrectly due to the empty name field in the database (
- This reply was modified 2 years, 8 months ago by vlasovdmitri.
Forum: Plugins
In reply to: [WooCommerce] How is an attribute value SLUG created?Perhaps something in the WordPress settings, because when I enter the value of the attribute in the admin panel, I also get
slug = $tag_id
and notslug = sanitize_title($name)
??- This reply was modified 2 years, 8 months ago by vlasovdmitri.
Forum: Plugins
In reply to: [WooCommerce] How is an attribute value SLUG created?Yes, I am assigning global attributes to the product, here is my code.
$attributes = wc_get_attribute_taxonomies(); foreach($product_data['atrebuts'] as $key=>$val){ foreach($attributes as $value){ if($value->attribute_label == $key){ if($val[0]){ wp_set_object_terms( $post_id, $val[0], 'pa_'.$value->attribute_name); $slug = $value->attribute_name; $terms = get_terms( array('taxonomy' => 'pa_' . $slug,'hide_empty' => false,)); foreach($terms as $term_id){ if ($term_id->slug==sanitize_title($val[0])){$term_id_id=$term_id->term_id;$term_tax_id=$term_id->term_id;} } $new_attr = new WC_Product_Attribute(); $new_attr->set_id( $term_id_id ); $new_attr->set_name('pa_'.$slug); $new_attr->set_options([$term_tax_id]); $new_attr->set_visible( true ); $parent_attributes['pa_' . $slug] = $new_attr; $product->set_attributes( array_values($parent_attributes) ); $arts['pa_'.$slug] = array( 'name' => 'pa_'.$slug, 'value' =>[$term_tax_id], 'postion' => '0', 'is_visible' => '1', 'is_variation' => '0', 'is_taxonomy' => '1' ); } } } } $product->save(); update_post_meta( $post_id, '_product_attributes', $arts);
But there is a nuance here, when determining the term_id, I cannot correctly determine this ID for all parameters.
If you check by name, then there is a problem with a dot and a comma, you get a different name for the same values. You can try to bring it to one type, but the slug has exactly a unique meaning and you don’t need to connect various functions, and here I can’t understand why the slug began to turn out as an ID, and not
sanitize_title($name)
Forum: Plugins
In reply to: [WooCommerce] How is an attribute value SLUG created?Thank You!
The forum says that you have some kind of addon
- This reply was modified 3 years, 1 month ago by vlasovdmitri.
I would like the vendors to add not their own product, but the admin product in the draft status, so I will hide the admin products from users.
On this page / store-manager / add-to-my-store-catalog /
there is no solution to this problem?
Sorry, I probably translated your question wrong. I, too, will not delete questions from the admin panel, but those that I deleted are not visible to users
Hi. Store-manager->settings->Module Controller->inquire OFF