<select class='wpsc_select_variation' name="variation[<?php 
        echo wpsc_vargrp_id();
        ?>
]" id="<?php 
        echo wpsc_vargrp_form_id();
        ?>
">
								<?php 
        while (wpsc_have_variations()) {
            wpsc_the_variation();
            ?>
									<option value="<?php 
            echo wpsc_the_variation_id();
            ?>
"  <?php 
            echo wpsc_the_variation_out_of_stock();
            ?>
 ><?php 
            echo wpsc_the_variation_name();
            ?>
</option>
								<?php 
        }
        ?>
								</select> 
							</p>
						<?php 
    }
    ?>
					</div>
					<?php 
function wpsc_add_to_cart_button($product_id, $return = false)
{
    global $wpdb, $wpsc_variations;
    $output = '';
    if ($product_id > 0) {
        // grab the variation form fields here
        $wpsc_variations = new wpsc_variations($product_id);
        if ($return) {
            ob_start();
        }
        ?>
			<div class='wpsc-add-to-cart-button'>
				<form class='wpsc-add-to-cart-button-form' id='product_<?php 
        echo esc_attr($product_id);
        ?>
' action='' method='post'>
					<?php 
        do_action('wpsc_add_to_cart_button_form_begin');
        ?>
					<div class='wpsc_variation_forms'>
						<?php 
        while (wpsc_have_variation_groups()) {
            wpsc_the_variation_group();
            ?>
							<p>
								<label for='<?php 
            echo wpsc_vargrp_form_id();
            ?>
'><?php 
            echo esc_html(wpsc_the_vargrp_name());
            ?>
:</label>
								<select class='wpsc_select_variation' name='variation[<?php 
            echo wpsc_vargrp_id();
            ?>
]' id='<?php 
            echo wpsc_vargrp_form_id();
            ?>
'>
									<?php 
            while (wpsc_have_variations()) {
                wpsc_the_variation();
                ?>
										<option value='<?php 
                echo wpsc_the_variation_id();
                ?>
' <?php 
                echo wpsc_the_variation_out_of_stock();
                ?>
><?php 
                echo esc_html(wpsc_the_variation_name());
                ?>
</option>
									<?php 
            }
            ?>
								</select>
							</p>
						<?php 
        }
        ?>
					</div>
					<input type='hidden' name='wpsc_ajax_action' value='add_to_cart' />
					<input type='hidden' name='product_id' value='<?php 
        echo $product_id;
        ?>
' />
					<input type='submit' id='product_<?php 
        echo $product_id;
        ?>
_submit_button' class='wpsc_buy_button' name='Buy' value='<?php 
        echo __('Add To Cart', 'wpsc');
        ?>
'  />
					<?php 
        do_action('wpsc_add_to_cart_button_form_end');
        ?>
				</form>
			</div>
		<?php 
        if ($return) {
            return ob_get_clean();
        }
    }
}
							<h4><?php echo __('Upload a File', 'wpsc'); ?></h4>
							<?php echo __('Select a file from your computer to include with this purchase.  ', 'wpsc'); ?><br />
							<input type='file' name='custom_file' value=''  />
						</div>
					<?php endif; ?>
					
					
					<?php /** the variation group HTML and loop */?>
					<div class="wpsc_variation_forms">
						<?php while (wpsc_have_variation_groups()) : wpsc_the_variation_group(); ?>
							<p>
								<label for="<?php echo wpsc_vargrp_form_id(); ?>"><?php echo wpsc_the_vargrp_name(); ?>:</label>
								<?php /** the variation HTML and loop */?>
								<select class='wpsc_select_variation' name="variation[<?php echo wpsc_vargrp_id(); ?>]" id="<?php echo wpsc_vargrp_form_id(); ?>">
								<?php while (wpsc_have_variations()) : wpsc_the_variation(); ?>
									<option value="<?php echo wpsc_the_variation_id(); ?>" <?php echo wpsc_the_variation_out_of_stock(); ?>><?php echo wpsc_the_variation_name(); ?></option>
								<?php endwhile; ?>
								</select> 
							</p>
						<?php endwhile; ?>
					</div>
					<?php /** the variation group HTML and loop ends here */?>
									
					
					<!-- THIS IS THE QUANTITY OPTION MUST BE ENABLED FROM ADMIN SETTINGS -->
					<?php if(wpsc_has_multi_adding()): ?>
						<fieldset>
						<label class='wpsc_quantity_update' for='wpsc_quantity_update[<?php echo wpsc_the_product_id(); ?>]'><?php echo __('Quantity', 'wpsc'); ?>:</label>
						
						<input type="text" id='wpsc_quantity_update' name="wpsc_quantity_update[<?php echo wpsc_the_product_id(); ?>]" size="2" value="1"/>
						<input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>"/>
Exemple #4
0
function wpsc_add_to_cart_button($product_id, $replaced_shortcode = false)
{
    global $wpdb, $wpsc_variations;
    if ($product_id > 0) {
        // grab the variation form fields here
        $wpsc_variations = new wpsc_variations($product_id);
        $output .= "<form onsubmit='submitform(this);return false;'  action='' method='post'>";
        /** the variation group HTML and loop */
        $output .= "<div class='wpsc_variation_forms'>";
        while (wpsc_have_variation_groups()) {
            wpsc_the_variation_group();
            $output .= "<p>";
            $output .= "<label for='" . wpsc_vargrp_form_id() . "'>" . wpsc_the_vargrp_name() . ":</label>";
            /** the variation HTML and loop */
            $output .= "<select class='wpsc_select_variation' name='variation[" . wpsc_vargrp_id() . "]' id='" . wpsc_vargrp_form_id() . "'>";
            while (wpsc_have_variations()) {
                wpsc_the_variation();
                $output .= "<option value='" . wpsc_the_variation_id() . "' " . wpsc_the_variation_out_of_stock() . ">" . wpsc_the_variation_name() . "</option>";
            }
            $output .= "</select> ";
            $output .= "</p>";
        }
        $output .= "</div>";
        /** the variation group HTML and loop ends here */
        $output .= "<input type='hidden' name='wpsc_ajax_action' value='add_to_cart' />";
        $output .= "<input type='hidden' name='product_id' value='" . $product_id . "' />";
        $output .= "<input type='hidden' name='item' value='" . $product_id . "' />";
        if (isset($wpsc_theme) && is_array($wpsc_theme) && $wpsc_theme['html'] != '') {
            $output .= $wpsc_theme['html'];
        } else {
            $output .= "<input type='submit' id='product_" . $product['id'] . "_submit_button' class='wpsc_buy_button' name='Buy' value='" . __('Add To Cart', 'wpsc') . "'  />";
        }
        $output .= '</form>';
        if ($replaced_shortcode == true) {
            return $output;
        } else {
            echo $output;
        }
    }
}