includes/admin/create-products.php
##This function is used create Attributes
This function is used create Attributes
This function is used create Attributes
public function create_attribute($attribute_name) {
	    global $wpdb;
		$return = array();    
		try{
			$attribute = array(
			  'attribute_label'   => $attribute_name,
			  'attribute_name'    => str_replace(" ","-",strtolower($attribute_name)),
			  'attribute_type'    => 'select',
			  'attribute_orderby' => 'menu_order',
			  'attribute_public'  => 0,
			);
			$check_existance = $wpdb->get_row("SELECT * FROM ".$wpdb->prefix . "woocommerce_attribute_taxonomies WHERE attribute_name ='".str_replace(" ","-",strtolower($attribute_name))."'");
			if(empty($check_existance)){
				$wpdb->insert( $wpdb->prefix . 'woocommerce_attribute_taxonomies', $attribute );
			}
			$return['attribute_slug'] = str_replace(" ","-",strtolower($attribute_name));
			$name  = wc_attribute_taxonomy_name( $attribute_name );
			$label = $attribute_name;
			delete_transient( 'wc_attribute_taxonomies' );
			clean_taxonomy_cache( $attroibute_name );
			global $wc_product_attributes;
			$wc_product_attributes = array();
			foreach ( wc_get_attribute_taxonomies() as $tax ) {
				if ( $name = wc_attribute_taxonomy_name( $tax->attribute_name ) ) {
					$wc_product_attributes[ $name ] = $tax;
				}
			}
			return $return;
		}catch (Exception $e) 
		{
			$wc_arcavis_shop->logError('create_attribute '.$e->getMessage());
			return $return;
		}
	}
public function create_attribute ( $ attribute_name ) { global $ wpdb ; $ return = array ( ) ; try { $ attribute = array ( 'attribute_label' => $ attribute_name , 'attribute_name' => str_replace ( " " , " - " , strtolower ( $ attribute_name ) ) , 'attribute_type' => 'select' , 'attribute_orderby' => 'menu_order' , 'attribute_public' => 0 , ) ; $ check_existance = $ wpdb -> get_row ( " SELECT * FROM  " . $ wpdb -> prefix . " woocommerce_attribute_taxonomies WHERE attribute_name =' " . str_replace ( " " , " - " , strtolower ( $ attribute_name ) ) . " ' " ) ; if ( empty ( $ check_existance ) ) { $ wpdb -> insert ( $ wpdb -> prefix . 'woocommerce_attribute_taxonomies' , $ attribute ) ; } $ return [ 'attribute_slug' ] = str_replace ( " " , " - " , strtolower ( $ attribute_name ) ) ; $ name = wc_attribute_taxonomy_name ( $ attribute_name ) ; $ label = $ attribute_name ; delete_transient ( 'wc_attribute_taxonomies' ) ; clean_taxonomy_cache ( $ attroibute_name ) ; global $ wc_product_attributes ; $ wc_product_attributes = array ( ) ; foreach ( wc_get_attribute_taxonomies ( ) as $ tax ) { if ( $ name = wc_attribute_taxonomy_name ( $ tax -> attribute_name ) ) { $ wc_product_attributes [ $ name ] = $ tax ; } } return $ return ; } catch ( Exception $ e ) { $ wc_arcavis_shop -> logError ( 'create_attribute ' . $ e -> getMessage ( ) ) ; return $ return ; } }
This function is used create Attributes
This function is used create Attributes
// Create attribute // Register the taxonomy