Tagged: add to cart, pricing, variable, variation
-
AuthorPosts
-
November 17, 2016 at 11:53 am #713523
Hi there,
we use avia for our product pages. Unfortunately the stock of the avia price button does not reflect reality. It always displays “6” on all products.
Example:
Please let me know how to fix this. Thank you!
Best,
ElmarNovember 20, 2016 at 10:05 am #714448Hey aerobis,
Sorry for the late reply and thanks for the login details. I think the account doesn’t have enough right for us to access the backend though, I get the following message when trying to access the WordPress backend:
Du bist leider nicht berechtigt, auf diese Website zuzugreifen.
Best regards,
RikardNovember 20, 2016 at 10:13 am #714450Hey Rikard, appreciated. The login only gets enabled on request. The good thing is that I solved the “issue”. We are using chained products and the chained product limits the overall availability of the main product. So actually it was not a bug – just hard to understand whats going on.
What would be awesome is that you support woocommerce a little Noten seriously with enfold. Especially the add-to-cart button could use some love. We fixed the price display ourselves but I think it should be baked into enfold.
Other than that – great theme!
November 20, 2016 at 11:20 am #714455Hey!
Feel free to share your solution, or what you modified, so we can send it to Kriesi.
If he checks and things we can go ahead with that, he will for sure include ro the theme.Thanks a lot for your understanding
Regards,
BasilisNovember 20, 2016 at 12:00 pm #714468The price hack is based on this solution here:
https://kriesi.at/support/topic/woocommerce-products-price-display-when-using-avia-layout-architect/It does work but I propose this to be a standard feature. All shops are based on prices and not being able to show the price as well as the price of the variation is a problem.
Additionally we did some custom programming to also show the product variation pricing and to sync several add-to-cart boxes on the same product page (we have on on top and one on the bottom):
Javascript:
jQuery(function($) { function aerobis_display_price() { var variations_data = jQuery.parseJSON($(".variations_form").attr("data-product_variations")); return variations_data; } if ($(".variations_form select").val() != "") { var variations_data = aerobis_display_price(); //console.log(variations_data); } $(document).on("change", ".variations_form select", function() { var selected_box = $(this); var selected = $(this).val(); var selected_text = $('option:selected', this).text(); var select_name = $(this).attr('name'); if (selected != "") { var selected_number = Number($(this).prop("selectedIndex")) - 1; $('.variations_form select[name=' + select_name + ']').each(function(selecta) { if ($(this).find('option[value="' + selected + '"]').length == 0) { // not exist in #select-2 $('.variations_form select[name=' + select_name + ']').append('<option value="' + selected + '" selected="selected">' + selected_text + '</option>'); } }); if (selected != '') { $('.variations_form select[name=' + select_name + ']').val(selected); } var selected_attr = new Array(); var select_boxes = $(this).parent().parent().parent().parent().find('select'); console.log(select_boxes); $(select_boxes).each(function(i, item) { console.log(item); selected_attr[i] = $(this).find(":selected").val() }); console.log(selected_attr); //$(".variations_form select").prop("selectedIndex", $(this).prop("selectedIndex")); // console.log( selected_number); var variations_data = aerobis_display_price(); //console.log(variations_data); // $('.variations_form select[name=' +select_name + ']').trigger('change'); var selected_product_id = 0; var selected_count = selected_attr.length; $.each(variations_data, function(i, item) { var var_count = 0; $.each(item.attributes, function(key, att) { if (jQuery.inArray(att, selected_attr) != -1) { var_count++; } }); if (var_count == selected_count) { selected_product_id = variations_data[i].variation_id; } }); //console.log(selected_product_id); jQuery.post(avia_framework_globals.ajaxurl, { "action": "aerobis_format_money", "product_id": selected_product_id }, function(response) { //console.log(response); $('._variation_price').empty(); $('.woocommerce-variation').before('<p class="price _variation_price">' + response + '</p>'); }); } }); });
Functions.php
function aerobis_format_money() { global $wpdb; $product = new WC_Product($_POST['product_id']); if ($product->get_price_including_tax() > 0) { echo woocommerce_price($product->get_price_including_tax()); } wp_die(); } add_action('wp_ajax_aerobis_format_money', 'aerobis_format_money'); add_action('wp_ajax_nopriv_aerobis_format_money', 'aerobis_format_money'); function aerobis_enqueue_scripts() { wp_enqueue_script('aerobis-js-scripts', get_stylesheet_directory_uri() . '/js/scripts.js'); add_action('wp_enqueue_scripts', 'aerobis_enqueue_scripts');
I hope this helps others and saves you guys time and money. Again, I think this should go into the standard theme but until it does – use my code for free.
Code in action: fitnessgeräte von aerobis
Best,
ElmarNovember 20, 2016 at 3:52 pm #714520Hey!
We have notified Kriesi for it!
Thanks a lot for sharing the code and the solution, we do appreciate it a lotCheers!
Basilis -
AuthorPosts
- You must be logged in to reply to this topic.