Skip Navigation

[Resuelto] Split: Overide woocommerce price with extra field calcutation – display regular price

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem:
Split: Overide woocommerce price with extra field calcutation - display regular price

Solution:
You can use "action_woocommerce_process_product_meta" hook to update the Woocommrece product field values.

You can find the proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/split-overide-woocommerce-price-with-extra-field-calcutation-display-regular-price/#post-1111518

Relevant Documentation:

This support ticket is created hace 6 años, 2 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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)

Este tema contiene 16 respuestas, tiene 2 mensajes.

Última actualización por domenicoS hace 6 años, 2 meses.

Asistido por: Minesh.

Autor
Mensajes
#1111344

I don't see the price. I0ve add the following shorte code in the layout to display it but nothing is displayed

[wpv-woo-product-price]
[wpv-woo-buy-options]

The price and button should be displayed under the table "Prenotazione e Partenze" in the frontend page of the product I share you in the first post

#1111347

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - to use the shortcodes [wpv-woo-product-price] and [wpv-woo-buy-options] you need to install the woocommerce views plugin.
=> https://toolset.com/documentation/user-guides/getting-started-woocommerce-views/

More info about shortcodes:
=> https://toolset.com/documentation/user-guides/views-shortcodes/#woocommerce-views

#1111363

Hi, I've already installed all plugins (view, layout, types)

#1111385

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Well - Did you installed Woocommerce Views plugin?

You can download it from here:
=> https://toolset.com/download/toolset-woocommerce-views/

#1111386

Yes, I installed all toolset plugin package

#1111388

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Ok - where exactly you are trying to display the [wpv-woo-product-price] and [wpv-woo-buy-options] shortcodes?

Could you please share the link of that page.

#1111390

this is the page => enlace oculto

The price and add to cart button should be under the table "Prenotazioni e partenze" and on the rigt of "Come Funziona"

This is tha layout I0m using => enlace oculto

#1111406

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Ok - I see views and Types and Forms plugin are not updated on your installed. Can I update it to latest official release version?

#1111410

I've update all, now I see this:

Price =

Buy Option ==

#1111424

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Ok - that I added to check and I removed all.

This is a strange thing as I just checked with the minimum install and both shortcodes just work fine.

Could you please check your issue by switching your theme to 2017 for a moment and check if you able to see the shortcode output.

#1111440

Hi Minesh,

The roblem is not linked to the theme, i tried to change it and it doen't display the button and price.

MAybe there is somethng with the plugin TM Woocommerce extra product.
This plugin allow to build a custom option with price dirclty in the product page.
If I put a fied with the price the button is dislayed, else not.

#1111442

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Ok - so I do not know how that plugin works. Could you please check with plugin author what causes the issue and if its Toolset, I would be happy to help. Please update me here.

#1111451

Hi, I find the issue. It is not linked to the plugin.

The issue is related to the code you suggest me to change the woocommerce price.

If I add set the price in the traditional woocommerce section it work, and both are displayed

If I add the brice using the custom field I don't know why but the price is correcly displayed in backend but not in frontend.

So, the issue maybe could be in the way the price is saved with the function?

#1111518

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Well - I use following code now:


function action_woocommerce_process_product_meta($post_id){ 
    global $woocommerce, $post;
	
		$option = $_POST['wpcf']['option-1'];
		$price1 = $_POST['wpcf']['prezzo-1'];
		$price2 = $_POST['wpcf']['prezzo-2'];
		$price3 = $_POST['wpcf']['prezzo-3'];
		$price4 = $_POST['wpcf']['prezzo-4'];
		$na = $_POST['wpcf']['na'];
		$nc = $_POST['wpcf']['nc'];    
		
		$regular_price = ($price1 * $na) + ($price2 * $nc)+ $price3 + $price4;
		
		update_post_meta($post_id,'_regular_price',$regular_price);
		   
}
add_action('woocommerce_process_product_meta', 'action_woocommerce_process_product_meta', 30, 2 ); 

It updates the regular price dynamically and I see the button on the frontend. Is this expected result?

#1111638

No Minesh, sorry.

I try to update the custom field with the price and save. Total was 60 but displayed is 100.

100 is the value I save before fill the traditional field of woocommerce to the bottom of the prooduct.

Updating the custom filed the price is not updated too