Home › Forum › Problemi Vari con WP › Woocommerce: Pagina Prodotto, non aggiunge attributi e quantità
Visualizzazione 0 filoni di risposte
-
AutorePost
-
-
3 Febbraio 2017 alle 9:58 #31280robyonePartecipante
Ciao Ragazzi, sto realizzando un tema Woocommerce custom. Nella pagina prodotto ho aggiunto una serie di select che si auto compilano con gli attributi del prodotto e un input per aggiungere la quantità .
Il problema è che, selezionando gli attributi e la quantità , e premendo il pulsante “aggiungi al carrello”, non vengono aggiunti gli attributi e neanche le quantità (ma prende la quantità 1 di default e gli attributi di default.
Come posso risolvere? via allego il codice completo della pagina single-product.php
Grazie in anticipo
<?php
/**
* The Template for displaying all single products
*
* This template can be overridden by copying it to yourtheme/woocommerce/single-product.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
global $product;
get_header( 'shop' ); ?>
<?php
/**
* woocommerce_before_main_content hook.
*
* @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
* @hooked woocommerce_breadcrumb - 20
*/
do_action( 'woocommerce_before_main_content' );
?>
<?php
// Availability
$availability = $product->get_availability();
$availability_html = empty( $availability ) ? '' : '<p class="stock ' . esc_attr( $availability ) . '">' . esc_html( $availability ) . '</p>';
echo apply_filters( 'woocommerce_stock_html', $availability_html, $availability, $product );
?>
<?php if ( $product->is_in_stock() ) : ?>
<?php do_action( 'woocommerce_before_add_to_cart_form' ); ?>
<form class="cart" method="post" enctype='multipart/form-data'>
<?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="altezza-17"></div>
<?php the_title( '<h1 itemprop="name" class="titolo-prodotto">', '</h1>' ); ?>
<div class="altezza-20"></div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="row">
<div class="col-md-12">
<?php
if ( has_post_thumbnail() ) {
$attachment_count = count( $product->get_gallery_attachment_ids() );
$gallery = $attachment_count > 0 ? '[product-gallery]' : '';
$props = wc_get_product_attachment_props( get_post_thumbnail_id(), $post );
$image = get_the_post_thumbnail( $post->ID, apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ), array(
'title' => $props,
'alt' => $props,
) );
echo apply_filters(
'woocommerce_single_product_image_html',
sprintf(
'%s',
esc_url( $props ),
esc_attr( $props ),
$gallery,
$image
),
$post->ID
);
} else {
echo apply_filters( 'woocommerce_single_product_image_html', sprintf( '', wc_placeholder_img_src(), __( 'Placeholder', 'woocommerce' ) ), $post->ID );
}
//do_action( 'woocommerce_product_thumbnails' );
?>
</div>
</div>
</div>
<div class="col-md-8">
<div class="row">
<div class="col-md-4">
/icone/check.png" width="30px">
</div>
<div class="col-md-8">
<p class="prod-disponibile-varianti"> Prodotto disponibile </p>
</div>
</div>
<div class="row">
<div class="col-md-3">
<span class="prezzo-prodotto-barrato">
<s><?php echo $product->get_regular_price()?><?php echo get_woocommerce_currency_symbol("EUR");?></s>
</span>
<span class="prezzo-prodotto" style="padding-right:25px;"><?php echo $product->get_sale_price() ?><?php echo get_woocommerce_currency_symbol("EUR");?></span>
</div>
<div class="col-md-3" style="padding-left: 30px;">
<div class="row">
<?php
if ( ! $product->is_sold_individually() ) {
woocommerce_quantity_input( array(
'min_value' => apply_filters( 'woocommerce_quantity_input_min', 1, $product ),
'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->backorders_allowed() ? '' : $product->get_stock_quantity(), $product ),
'input_value' => ( isset( $_POST ) ? wc_stock_amount( $_POST ) : 1 )
) );
}
?>
</div>
</div>
</div>
<div class="altezza-20"></div>
<?php the_content(); ?>
<?php
// Get product attributes
$attributes = $product->get_attributes();
if ( $attributes ) {
?>
<div class="altezza-20"></div>
Scegli la variante che fa per te
<div class="altezza-20"></div>
<?php
}
?>
<div class="row">
<?php
// Get product attributes
$attributes = $product->get_attributes();
if ( ! $attributes ) {
//echo "No attributes";
}
foreach ( $attributes as $attribute ) {
?>
<div class="col-md-6">
<?php echo $attribute . ": "; ?>
<div class="select-style">
<?php
//echo $attribute . ": ";
$product_attributes = array();
$product_attributes = explode('|',$attribute);
$attributes_dropdown = '<select><option>Seleziona</option>';
?>
<?php
foreach ( $product_attributes as $pa ) {
$attributes_dropdown .= '<option value="' . $pa . '">' . $pa . '</option>';
}
$attributes_dropdown .= '</select>';
echo $attributes_dropdown;
?>
</div>
<div class="altezza-20"></div>
</div>
<?php
}
?>
<?php do_action( 'woocommerce_after_add_to_cart_button' ); ?>
</form>
<?php do_action( 'woocommerce_after_add_to_cart_form' ); ?>
<?php endif; ?>
</div>
<!-- /prima riga -->
<div class="altezza-20"></div>
<div class="row altezza-40">
<div class="col-md-6">
<!-- riempitivo -->
</div>
<div class="col-md-6" style="padding-left: 28px;">
<div class="row">
<div class="hidden-xs hidden-sm col-md-9" style="padding-left: 20px;">
<?php
get_template_part('btk-parts/button-single-product')
?>
</div>
<div class="hidden-ms hidden-lg text-center col-md-9">
<!-- riempitivo -->
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="pagina-attrib-margin-top container">
<div class="row">
<div class="col-md-12">
<!-- pannello -->
<div class="wrapper">
<div class="tabs">
<div class="tab" >
<input type="radio" name="css-tabs" id="tab-1" checked class="tab-switch">
<label for="tab-1" class="tab-label">Descrizione</label>
<div class="tab-content">
<?php the_title( '<h2 itemprop="name" class="titolo-prodotto">', '</h2>' ); ?>
<div class="altezza-20"></div>
<?php echo woocommerce_template_single_excerpt(); ?>
<?php the_content(); ?>
</div>
</div>
<div class="tab">
<input type="radio" name="css-tabs" id="tab-2" class="tab-switch">
<label for="tab-2" class="tab-label">Recensioni</label>
<div class="tab-content">
<div class="altezza-20"></div>
<?php
get_template_part('btk-parts/recensioni')
?>
</div>
</div>
</div>
</div>
<!-- pannello -->
</div>
</div>
</div>
<?php
echo woocommerce_output_related_products();
?>
<?php
/**
* woocommerce_after_main_content hook.
*
* @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
*/
do_action( 'woocommerce_after_main_content' );
?>
<?php
/**
* woocommerce_sidebar hook.
*
* @hooked woocommerce_get_sidebar - 10
*/
do_action( 'woocommerce_sidebar' );
?>
<?php get_footer( 'shop' ); ?>
-
-
AutorePost
Visualizzazione 0 filoni di risposte
- Devi essere connesso per rispondere a questo topic.