{"id":13564,"date":"2017-06-19T08:16:44","date_gmt":"2017-06-19T06:16:44","guid":{"rendered":"https:\/\/it.wordpress.org\/support\/topic\/help-sistemazione-codice-tema-functions-php\/"},"modified":"2017-06-20T09:18:36","modified_gmt":"2017-06-20T07:18:36","slug":"help-sistemazione-codice-tema-functions-php","status":"closed","type":"topic","link":"https:\/\/it.wordpress.org\/support\/topic\/help-sistemazione-codice-tema-functions-php\/","title":{"rendered":"Help sistemazione codice tema functions.php"},"content":{"rendered":"<p>Ciao  a tutti, ho aggiunto del codice al file functions.php, per\u00f2 come potete vedere non \u00e8 correttamente centrato ecc ecc, io non sono capace di sistemarlo,<br \/>\npraticamente il pulsante delle quantit\u00e0 si sovrappone al tasto &#8220;aggiungi al carrello) inoltre non \u00e8 centrato<br \/>\nQualcuno potrebbe aiutarmi?<\/p>\n<p>codice:<\/p>\n<pre><code>&lt;?php\n\n\/**\n * Add quantity field on the archive page.\n *\/\nfunction custom_quantity_field_archive() {\n\t$product = wc_get_product( get_the_ID() );\n\tif ( ! $product-&gt;is_sold_individually() &amp;&amp; &#039;variable&#039; != $product-&gt;product_type &amp;&amp; $product-&gt;is_purchasable() ) {\n\t\twoocommerce_quantity_input( array( &#039;min_value&#039; =&gt; 1, &#039;max_value&#039; =&gt; $product-&gt;backorders_allowed() ? &#039;&#039; : $product-&gt;get_stock_quantity() ) );\n\t}\n}\nadd_action( &#039;woocommerce_after_shop_loop_item&#039;, &#039;custom_quantity_field_archive&#039;, 0, 9 );\n\/**\n * Add requires JavaScript.\n *\/\nfunction custom_add_to_cart_quantity_handler() {\n\twc_enqueue_js( &#039;\n\t\tjQuery( &quot;.post-type-archive-product&quot; ).on( &quot;click&quot;, &quot;.quantity input&quot;, function() {\n\t\t\treturn false;\n\t\t});\n\t\tjQuery( &quot;.post-type-archive-product&quot; ).on( &quot;change input&quot;, &quot;.quantity .qty&quot;, function() {\n\t\t\tvar add_to_cart_button = jQuery( this ).parents( &quot;.product&quot; ).find( &quot;.add_to_cart_button&quot; );\n\t\t\t\/\/ For AJAX add-to-cart actions\n\t\t\tadd_to_cart_button.data( &quot;quantity&quot;, jQuery( this ).val() );\n\t\t\t\/\/ For non-AJAX add-to-cart actions\n\t\t\tadd_to_cart_button.attr( &quot;href&quot;, &quot;?add-to-cart=&quot; + add_to_cart_button.attr( &quot;data-product_id&quot; ) + &quot;&amp;quantity=&quot; + jQuery( this ).val() );\n\t\t});\n\t&#039; );\n}\nadd_action( &#039;init&#039;, &#039;custom_add_to_cart_quantity_handler&#039; );\n\nadd_filter( &#039;woocommerce_product_add_to_cart_text&#039;, &#039;woo_archive_custom_cart_button_text&#039; );    \/\/ 2.1 +\nfunction woo_archive_custom_cart_button_text() {\nreturn __( &#039;Aggungi al carrello&#039;, &#039;woocommerce&#039; );\n}\n\nadd_filter( &#039;woocommerce_variable_sale_price_html&#039;, &#039;businessbloomer_remove_prices&#039;, 10, 2 );\nadd_filter( &#039;woocommerce_variable_price_html&#039;, &#039;businessbloomer_remove_prices&#039;, 10, 2 );\nadd_filter( &#039;woocommerce_get_price_html&#039;, &#039;businessbloomer_remove_prices&#039;, 10, 2 );\n \nfunction businessbloomer_remove_prices( $price, $product ) {\n$price = &#039;&#039;;\nreturn $price;\n}\n\nfunction show_stock() {\nglobal $product;\nif ( $product-&gt;stock ) { \/\/ if manage stock is enabled \nif ( number_format($product-&gt;stock,0,&#039;&#039;,&#039;&#039;) &lt; 3 ) { \/\/ if stock is low\necho &#039;&lt;div class=&quot;remaining&quot;&gt;Only &#039; . number_format($product-&gt;stock,0,&#039;&#039;,&#039;&#039;) . &#039; Kg disponibili!&lt;\/div&gt;&#039;;\n} else {\necho &#039;&lt;div class=&quot;remaining&quot;&gt;&#039; . number_format($product-&gt;stock,0,&#039;&#039;,&#039;&#039;) . &#039; Kg disponibili&lt;\/div&gt;&#039;; \n}\n}\n}\n \nadd_action(&#039;woocommerce_after_shop_loop_item&#039;,&#039;show_stock&#039;, 50);\nadd_action( &#039;wp_enqueue_scripts&#039;, &#039;enqueue_child_theme_styles&#039;, PHP_INT_MAX);\nadd_action( &#039;woocommerce_after_shop_loop_item_title&#039;, &#039;woocommerce_template_single_excerpt&#039;, 5);\nadd_action( &#039;woocommerce_before_add_to_cart_button&#039;, &#039;echo_qty_front_add_cart&#039; );\nfunction echo_qty_front_add_cart() {\n echo &#039;&lt;div class=&quot;qty&quot;&gt;KG: &lt;\/div&gt;&#039;; \n}\nfunction enqueue_child_theme_styles() {\n    \n    \/\/ Uncomment this section if you want your child&#039;s style.css to load.\n    \/*wp_enqueue_style( &#039;media_center-main-style&#039;, get_template_directory_uri().&#039;\/style.css&#039; );\n    wp_enqueue_style( &#039;child-style&#039;, get_stylesheet_uri(), array(&#039;media_center-main-style&#039;)  );*\/\n    \/\/ Uncomment this section to activate RTL from child theme\n    \/*\n    if( is_rtl() ) {\n        wp_enqueue_style( &#039;media_center-rtl-style&#039;, get_template_directory_uri().&#039;\/rtl.css&#039; );\n    }*\/\n}<\/code><\/pre>\n<p>Grazie<\/p>\n","protected":false},"template":"","class_list":["post-13564","topic","type-topic","status-closed","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/it.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/13564","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/it.wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/it.wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/it.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/13564\/revisions"}],"predecessor-version":[{"id":13616,"href":"https:\/\/it.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/13564\/revisions\/13616"}],"wp:attachment":[{"href":"https:\/\/it.wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=13564"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}