}
    ?>
					
					
					<!-- END OF QUANTITY OPTION -->
					<?php 
    if (get_option('hide_addtocart_button') == 0 && get_option('addtocart_or_buynow') != '1') {
        ?>
						<?php 
        if (wpsc_product_has_stock()) {
            ?>
							<?php 
            if (wpsc_product_external_link(wpsc_the_product_id()) != '') {
                ?>
										<?php 
                $action = wpsc_product_external_link(wpsc_the_product_id());
                ?>
										<input class="wpsc_buy_button" type='button' value='<?php 
                echo __('Buy Now', 'wpsc');
                ?>
' onclick='gotoexternallink("<?php 
                echo $action;
                ?>
")'>
										<?php 
            } else {
                ?>
									<input type='image' src='<?php 
                echo WPSC_URL;
                ?>
/themes/iShop/images/buy_button.gif' id='product_<?php 
/**
 * wpsc_get_form_action
 *
 * Return the form action for use in the template files
 *
 * @global <type> $wpec_form_action
 * @return <type>
 */
function wpsc_get_form_action()
{
    global $wpec_form_action;
    $product_id = wpsc_the_product_id();
    // Function has already ran in this page load
    if (isset($wpec_form_action)) {
        $action = $wpec_form_action;
        // No global so figure it out
    } else {
        // Use external if set
        if (wpsc_is_product_external()) {
            $action = wpsc_product_external_link($product_id);
            // Otherwise use this page
        } else {
            $action = wpsc_this_page_url();
        }
    }
    // Return form action
    return $action;
}
    <?php 
    }
    ?>

    <?php 
    if (get_option('hide_addtocart_button') == 0 && get_option('addtocart_or_buynow') != '1') {
        ?>
      <?php 
        if (wpsc_product_has_stock()) {
            ?>

        <?php 
            if (wpsc_product_external_link($product_id) != '') {
                ?>
          <?php 
                $action = wpsc_product_external_link($product_id);
                ?>
          <button class="button big active"
                  onclick="return gotoexternallink('<?php 
                echo $action;
                ?>
', '<?php 
                echo wpsc_product_external_link_target($product_id);
                ?>
')">
            <span><?php 
                echo wpsc_product_external_link_text($product_id, __('Buy Now', ETHEME_DOMAIN));
                ?>
</span>
          </button>
        <?php 
/**
 * wpsc_is_product_external( $product_id = 0 )
 *
 * Checks if current product is external.
 *
 * @param int $product_id
 */
function wpsc_is_product_external($product_id = 0)
{
    // Get product ID if incorrect value was passed
    if (empty($product_id) || !is_numeric($product_id)) {
        $product_id = wpsc_the_product_id();
    }
    // Get external link
    $external_link = wpsc_product_external_link($product_id);
    // Use external if set
    if (!empty($external_link)) {
        return true;
    } else {
        return false;
    }
}
Example #5
0
/**
 * Create product slider getting query
 */
function etheme_create_slider($args, $title = false, $image_width = 220, $image_height = 220, $crop = false)
{
    global $wpdb;
    $box_id = rand(1000, 10000);
    $multislides = new WP_Query($args);
    if ($multislides->have_posts()) {
        if ($title) {
            $title_output = '<h2 class="slider-title">' . $title . '</h2>';
        }
        echo '<div class="product-slider">';
        echo $title_output;
        echo '<div class="clear"></div>';
        echo '<div class="carousel">';
        echo '<div class="slider">';
        $_i = 0;
        while ($multislides->have_posts()) {
            $multislides->the_post();
            $_i++;
            if (class_exists('Woocommerce')) {
                global $product;
                if (!$product->is_visible()) {
                    continue;
                }
                echo '<div class="slide product-slide ' . $last . '">';
                woocommerce_get_template_part('content', 'product');
                echo '</div><!-- slide -->';
            }
            if (class_exists('WP_eCommerce')) {
                $post_id = get_the_ID();
                $post_name = get_the_title();
                $post_image = etheme_get_image(null, $image_width, $image_height, $crop, $post_id);
                if (!$post_image && $image_default) {
                    $post_image = $image_default;
                }
                $post_url = get_permalink();
                if (class_exists('WP_eCommerce')) {
                    $normal_price = class_exists('WP_eCommerce') ? the_product_price($post_id) : false;
                    $post_price = class_exists('WP_eCommerce') ? the_product_price($post_id, true) : '';
                }
                echo '<div class="slide product-slide ' . $last . '">';
                echo '<a href="' . $post_url . '" class="product-image"><div class="img-wrapper"><img alt="" src="' . $post_image . '" /></div></a>';
                echo '<span class="product-name"><a href="' . $post_url . '">' . esc_attr($post_name) . '</a></span>';
                if ($normal_price != $post_price) {
                    echo '<div class="price sale">';
                    echo '<p class="oldprice-p pricedisplay"><span class="oldprice">' . $normal_price . '</span></p>';
                    echo '<p class="pricedisplay"><span class="currentprice pricedisplay">' . $post_price . '</span></p>';
                    echo '</div> ';
                } else {
                    echo '<div class="price">';
                    echo '<span>' . $post_price . '</span>';
                    echo '</div>';
                }
                wpsc_the_product();
                if (wpsc_product_external_link($post_id) != '') {
                    $action = wpsc_product_external_link($post_id);
                } else {
                    $action = htmlentities(wpsc_this_page_url(), ENT_QUOTES, 'UTF-8');
                }
                echo '<div class="btn-cont">';
                echo '<form class="product_form"  enctype="multipart/form-data" action="' . $action . '" method="post" name="product_' . $post_id . '" id="product_' . $post_id . '" >';
                echo '<input type="hidden" value="add_to_cart" name="wpsc_ajax_action"/>';
                echo '<input type="hidden" value="' . $post_id . '" name="product_id"/>';
                if (false) {
                    echo '<button class="button" type="submit" id="product_' . $post_id . '_submit_button"><span>' . __('Add To Cart', 'wpsc') . '</span></button>';
                } else {
                    echo '<a href="' . $post_url . '" class="button add-to-cart sml"><span>' . __('Read more', 'wpsc') . '</span></a>';
                }
                echo '</form>';
                echo '</div>';
                echo '</div><!-- slide -->';
            }
            unset($last);
        }
        echo '</div><!-- slider -->';
        echo '</div><!-- carousel -->';
        if ($_i > 1) {
            echo '<div class="prev arrow' . $box_id . '" style="cursor: pointer; ">&nbsp;</div>';
            echo '<div class="next arrow' . $box_id . '" style="cursor: pointer; ">&nbsp;</div>';
        }
        echo '</div><!-- product-slider -->';
    }
    wp_reset_query();
    if (@$_i > 1) {
        echo '
            <script type="text/javascript">
                jQuery(".arrow' . $box_id . '.prev").addClass("disabled");
                jQuery(".carousel").iosSlider({
                    desktopClickDrag: true,
                    snapToChildren: true,
                    infiniteSlider: false,
                    navNextSelector: ".arrow' . $box_id . '.next",
                    navPrevSelector: ".arrow' . $box_id . '.prev",
                    lastSlideOffset: 3,
                    onFirstSlideComplete: function(){
                        jQuery(".arrow' . $box_id . '.prev").addClass("disabled");
                    },
                    onLastSlideComplete: function(){
                        jQuery(".arrow' . $box_id . '.next").addClass("disabled");
                    },
                    onSlideChange: function(){
                        jQuery(".arrow' . $box_id . '.next").removeClass("disabled");
                        jQuery(".arrow' . $box_id . '.prev").removeClass("disabled");
                    }
                });
            </script>
        ';
    }
}