ResolvedCatch variations of the Product.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #24928
    contato
    Participant

    Hello. Dear, the topic of you is very good. I put an order shipping button when the customer completes the purchase of items. At the end of the checkout on the Thank You screen, a button will appear for the customer to send the order paid and confirmed by WhatsApp from the restaurant, to speed up the confirmation. It happens that it is not taking the product variations. I’ll put my code here as a base and thank you if you help me in how I can get these variations of your plugin order.

    I am grateful.

    Code Here

    // Include product variation
    			    $include_variation = 'yes';			    
    			    if ( $item['variation_id'] > 0 && $_product->is_type( 'variable' ) && $include_variation === 'yes' ) {
    			    $variations = $_product->get_available_variations();
    			    foreach ($_product->get_attributes() as $taxonomy => $attribute_obj ) {
    			        // Get the attribute label
    			        $attribute_label_name = wc_attribute_label($taxonomy);
    			    }
    			    foreach( $_product->get_variation_attributes() as $taxonomy => $terms_slug ){
    			        // To get the attribute label (on WooCommerce 3+)
    			        $taxonomy_label = wc_attribute_label( $taxonomy, $_product );
    			        // Setting some data in an array
    			        $variations_attributes_and_values[$taxonomy] = array('label' => $taxonomy_label);
    			        foreach($terms_slug as $term) {
    			        	if( isset( $taxonomy->term_id ) ){
    			            // Getting the term slug slug object
    			            $term_obj  = get_term_by('slug', $term, $taxonomy, true);
    			            $term_id   = $term_obj->term_id; // The ID  <==  <==  <==  <==  <==  <==  Here
    			            $term_name = $term_obj->name; // O Name
    			            $term_slug = $term_obj->slug; // O Slug
    			            $variations[$term_slug] = get_post_meta( $variations[ 'variation_id' ], $term_slug, true );
    			            // $term_description = $term_obj->description; // The Description
    			            // Defining ID terms and values in the matrix
    			            $variations_attributes_and_values[$taxonomy]['terms'][$term_id] = array(
    			                'name'        => $term_name,
    			                'slug'        => $term_slug
    			            );
    			        	}
    			        }
    			    }
    			        // Recover data if a product has variation
    			        foreach( $item['variation'] as $variations ){
    			        	$variation_label = ucfirst($attribute_label_name);
    			            $product_variation = ucfirst($variations);
    			            $variation_output = "\r\n*".$variation_label.":* ".$product_variation."";
    			        }
    			    }
    			    else {
    			    	// Return empty, if not
    			    	$variation_output = '';
    			    }
    			    	$message.= "\r\n*".$product_name."*".$variation_output."*".$quantity_label.":* ".$qty."\r\n*".$price_label.":* ".$currency." ".$format_price." \r\n*".$url_label.":* ".$product_url."\r\n";
    			}
    #24935
    Althemist
    Keymaster

    Hello contato,

    I am not really sure what do you mean. However, it doesn’t sound theme related. You’d probably need to ask your WhatsApp plugin developer’s support team if it supports product meta data.

    Regards,
    Dimitar

    #24942
    contato
    Participant

    No, it is not a plugin, it is a code snippet. I need to get the variables that your plugin generates. In this case, I want to get the product variables that are created with your plugin.

    See the image.
    https://uploaddeimagens.com.br/imagens/TVei2gk
    https://uploaddeimagens.com.br/imagens/8ZvdPnY
    https://uploaddeimagens.com.br/imagens/l6EDHgM
    https://uploaddeimagens.com.br/imagens/j8w3u2c
    https://uploaddeimagens.com.br/imagens/H-XRMc4
    https://uploaddeimagens.com.br/imagens/8Nv-eTY

    #24948
    contato
    Participant

    No, it is not a plugin, it is a code snippet. I need to get the variables that your plugin generates. In this case, I want to get the product variables that are created with your plugin.

    See the image.






    #24947
    contato
    Participant
    This reply has been marked as private.
    #24955
    Althemist
    Keymaster

    These are not variables. They are addons. Not really sure if what you need is possible. I’ll ask our lead developer and CTO Alex to take a look and help if possible.

    Regards,
    Dimitar

    #24962
    Alex
    Keymaster

    Hello contato,

    Please look at following function, defined in lafka-plugin/incl/addons/lafka-product-addons.php
    lafka_get_product_addons( $post_id, $prefix, $inc_parent, $inc_global )

    In short, the product level addons you can take like this:
    $product_addons = array_filter( (array) $product->get_meta( '_product_addons' ) );

    And globally defined addons, like this:

    
    		$args = array(
    			'posts_per_page'   => - 1,
    			'orderby'          => 'meta_value',
    			'order'            => 'ASC',
    			'meta_key'         => '_priority',
    			'post_type'        => 'lafka_glb_addon',
    			'post_status'      => 'publish',
    			'suppress_filters' => true,
    			'meta_query'       => array(
    				array(
    					'key'   => '_all_products',
    					'value' => '1',
    				),
    			),
    		);
    		$global_addons = get_posts( $args );
    

    Regards,
    Alex

    #24963
    contato
    Participant
    This reply has been marked as private.
    #24965
    Althemist
    Keymaster

    Hello contato,

    The functions Alex gave are what you need to parse the product addons. We can’t write your custom function and third-party plugin integration as it goes far beyond the scope of our support. You’d need to do it by yourself.

    As for including the feature in the theme by default – I am afraid you’re the first and only one asking for such integration and also it’s beyond the theme building so currently we don’t have such plans.

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in and have valid license to reply to this topic.

License required for the following item
Login and Registration Log in · Register