Help sistemazione codice tema functions.php
-
Ciao a tutti, ho aggiunto del codice al file functions.php, però come potete vedere non è correttamente centrato ecc ecc, io non sono capace di sistemarlo,
praticamente il pulsante delle quantità si sovrappone al tasto “aggiungi al carrello) inoltre non è centrato
Qualcuno potrebbe aiutarmi?codice:
<?php /** * Add quantity field on the archive page. */ function custom_quantity_field_archive() { $product = wc_get_product( get_the_ID() ); if ( ! $product->is_sold_individually() && 'variable' != $product->product_type && $product->is_purchasable() ) { woocommerce_quantity_input( array( 'min_value' => 1, 'max_value' => $product->backorders_allowed() ? '' : $product->get_stock_quantity() ) ); } } add_action( 'woocommerce_after_shop_loop_item', 'custom_quantity_field_archive', 0, 9 ); /** * Add requires JavaScript. */ function custom_add_to_cart_quantity_handler() { wc_enqueue_js( ' jQuery( ".post-type-archive-product" ).on( "click", ".quantity input", function() { return false; }); jQuery( ".post-type-archive-product" ).on( "change input", ".quantity .qty", function() { var add_to_cart_button = jQuery( this ).parents( ".product" ).find( ".add_to_cart_button" ); // For AJAX add-to-cart actions add_to_cart_button.data( "quantity", jQuery( this ).val() ); // For non-AJAX add-to-cart actions add_to_cart_button.attr( "href", "?add-to-cart=" + add_to_cart_button.attr( "data-product_id" ) + "&quantity=" + jQuery( this ).val() ); }); ' ); } add_action( 'init', 'custom_add_to_cart_quantity_handler' ); add_filter( 'woocommerce_product_add_to_cart_text', 'woo_archive_custom_cart_button_text' ); // 2.1 + function woo_archive_custom_cart_button_text() { return __( 'Aggungi al carrello', 'woocommerce' ); } add_filter( 'woocommerce_variable_sale_price_html', 'businessbloomer_remove_prices', 10, 2 ); add_filter( 'woocommerce_variable_price_html', 'businessbloomer_remove_prices', 10, 2 ); add_filter( 'woocommerce_get_price_html', 'businessbloomer_remove_prices', 10, 2 ); function businessbloomer_remove_prices( $price, $product ) { $price = ''; return $price; } function show_stock() { global $product; if ( $product->stock ) { // if manage stock is enabled if ( number_format($product->stock,0,'','') < 3 ) { // if stock is low echo '<div class="remaining">Only ' . number_format($product->stock,0,'','') . ' Kg disponibili!</div>'; } else { echo '<div class="remaining">' . number_format($product->stock,0,'','') . ' Kg disponibili</div>'; } } } add_action('woocommerce_after_shop_loop_item','show_stock', 50); add_action( 'wp_enqueue_scripts', 'enqueue_child_theme_styles', PHP_INT_MAX); add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_single_excerpt', 5); add_action( 'woocommerce_before_add_to_cart_button', 'echo_qty_front_add_cart' ); function echo_qty_front_add_cart() { echo '<div class="qty">KG: </div>'; } function enqueue_child_theme_styles() { // Uncomment this section if you want your child's style.css to load. /*wp_enqueue_style( 'media_center-main-style', get_template_directory_uri().'/style.css' ); wp_enqueue_style( 'child-style', get_stylesheet_uri(), array('media_center-main-style') );*/ // Uncomment this section to activate RTL from child theme /* if( is_rtl() ) { wp_enqueue_style( 'media_center-rtl-style', get_template_directory_uri().'/rtl.css' ); }*/ }
Grazie
Stai visualizzando 5 risposte - dal 1 al 5 (di 5 totali)
Stai visualizzando 5 risposte - dal 1 al 5 (di 5 totali)
- Il topic ‘Help sistemazione codice tema functions.php’ è chiuso a nuove risposte.