{"id":232777,"date":"2023-01-28T10:04:00","date_gmt":"2023-01-28T07:04:00","guid":{"rendered":"https:\/\/wordpress.mediadoma.com\/?p=232777"},"modified":"2022-11-10T17:43:29","modified_gmt":"2022-11-10T14:43:29","slug":"come-mostrare-il-prezzo-normale-predefinito-per-woocommerce-wordpress-in-base-al-prezzo-di-vendita","status":"publish","type":"post","link":"https:\/\/wordpress.mediadoma.com\/it\/come-mostrare-il-prezzo-normale-predefinito-per-woocommerce-wordpress-in-base-al-prezzo-di-vendita\/","title":{"rendered":"Come mostrare il prezzo normale predefinito per Woocommerce\/WordPress in base al prezzo di vendita?"},"content":{"rendered":"<p><a href=\"https:\/\/helloacm.com\/how-to-remove-product-review-in-woocommercewordpress\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">Woocommerce<\/a> \u00e8 un potente plug-in\/framework che consente di creare un negozio online utilizzando WordPress. Puoi modificare gli attributi per ogni merce, ma a volte hai cos\u00ec tanti articoli che potrebbe essere necessario del tempo per aggiornare un particolare attributo per un articolo.<\/p>\n<p>Ad esempio, se hai dimenticato di inserire il prezzo normale per gli articoli, non verr\u00e0 mostrato un prezzo normale nei caratteri incrociati come ~100,00 GBP~. Ma sarebbe bello mettere il prezzo normale in modo che i clienti sentano che gli articoli sono in vendita (pi\u00f9 economici) e questo sicuramente aumenta il tasso di acquisto.<\/p>\n<p>Puoi scrivere un SQL complesso per aggiornare i metadati, ma sar\u00e0 rischioso e potrebbe non essere cos\u00ec flessibile rispetto al metodo seguente. Inserisci il seguente codice PHP nel template <strong>functions.php del tuo tema figlio<\/strong><\/p>\n<pre><code>function helloacm_regular_price( $price, $product) {\n\u00a0 $price_factor = 1.3; \/\/ show sale price * 1.3 \n\u00a0 $sale_price = $product-&gt;get_sale_price(); \/\/ get sale price\n\u00a0 if (!is_numeric($sale_price)) { \/\/ sale price not set\n\u00a0 \u00a0 return $price; \u00a0\/\/ return default price.\n\u00a0 }\n\u00a0 $exp_price = $sale_price * $price_factor; \u00a0\/\/ get expected regular price\n\u00a0 if ($price &gt; 0) { \u00a0\/\/ if regular price is filled\n\u00a0 \u00a0 if ($price &lt; $sale_price) { \/\/ if it is even smaller than sale price\n\u00a0 \u00a0 \u00a0 return $exp_price; \u00a0\/\/ return corrected regular price\n\u00a0 \u00a0 } \u00a0 \u00a0 \n\u00a0 \u00a0 return $price; \/\/ otherwise return the input regular price\n\u00a0 }\n\u00a0 return $exp_price; \/\/ return the default regular price\n}\nadd_filter( 'woocommerce_get_regular_price', 'helloacm_regular_price', 10, 2);<\/code><\/pre>\n<p>Questo \u00e8 tutto. Se il prezzo normale non viene inserito, mostrer\u00e0 il prezzo normale predefinito che \u00e8 <strong>$price_factor moltiplicato per<\/strong> il prezzo di vendita. In caso contrario, ci sar\u00e0 un controllo di sicurezza per garantire che il prezzo normale sia sempre superiore al prezzo di vendita.<\/p>\n<p>Questo non cambia il database, quindi \u00e8 considerato il modo pi\u00f9 sicuro per giocare brutti scherzi. Il filtro <strong>woocommerce_get_regular_price<\/strong> viene aggiunto prima di restituire il prezzo normale.<\/p>\n<p><div id=\"PostUnique_PostSource\" style=\"padding-top: 50px\">Fonte di registrazione:  <a target=\"_blank\" rel=\"noopener nofollow\" href=\"\/\/helloacm.com\" class=\"external external_icon\">helloacm.com<\/a><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Come mostrare il prezzo normale predefinito per Woocommerce\/WordPress in base al prezzo di vendita?<\/p>\n","protected":false},"author":1,"featured_media":223696,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_wp_rev_ctl_limit":""},"categories":[896,835,804,814,844,855,865],"tags":[1168],"class_list":["post-232777","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-codice","category-guida-per-principianti","category-php-6","category-plugin-2","category-tutorial","category-woocommerce-6","category-wordpress-6","tag-affiai-it"],"_links":{"self":[{"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/posts\/232777","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/comments?post=232777"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/posts\/232777\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/media\/223696"}],"wp:attachment":[{"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/media?parent=232777"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/categories?post=232777"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/tags?post=232777"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}