Exemplo n.º 1
0
function rcl_add_cart_button($content)
{
    global $post, $rmag_options;
    if ($post->post_type !== 'products') {
        return $content;
    }
    $metas = rcl_get_postmeta_array($post->ID);
    $price = $metas['price-products'];
    $outsale = $metas['outsale'];
    $button = '<div class="price-basket-product">';
    if (!$outsale) {
        if ($metas['availability_product'] == 'empty') {
            //если товар цифровой
            if ($price) {
                $button .= 'Цена: ' . rcl_get_price($post->ID) . ' <input type="text" size="2" name="number_product" id="number_product" value="1">';
            } else {
                $button .= 'Бесплатно ';
            }
            $button .= rcl_get_button('Добавить в корзину', '#', array('icon' => false, 'class' => 'add_basket', 'attr' => 'onclick="rcl_add_cart(this);return false;" data-product=' . $post->ID));
        } else {
            if ($rmag_options['products_warehouse_recall'] == 1) {
                $amount = get_post_meta($post->ID, 'amount_product', 1);
                if ($amount > 0 || $amount == false) {
                    $button .= 'Цена: ' . rcl_get_price($post->ID) . ' <input type="text" size="2" name="number_product" id="number_product" value="1">' . rcl_get_button('Добавить в корзину', '#', array('icon' => false, 'class' => 'add_basket', 'attr' => 'onclick="rcl_add_cart(this);return false;" data-product=' . $post->ID));
                }
            } else {
                $button .= 'Цена: ' . rcl_get_price($post->ID) . ' <input type="text" size="2" name="number_product" id="number_product" value="1">' . rcl_get_button('Добавить в корзину', '#', array('icon' => false, 'class' => 'add_basket', 'attr' => 'onclick="rcl_add_cart(this);return false;" data-product=' . $post->ID));
            }
        }
    }
    $button .= '</div>';
    $button = apply_filters('cart_button_product_page', $button);
    $content .= $button;
    return $content;
}
        <?php 
if (has_post_thumbnail()) {
    ?>
                <div class="thumb-prod" width="110">
                        <?php 
    the_post_thumbnail(array(100, 100));
    ?>
                </div>
        <?php 
}
?>

        <div class="product-content">

            <?php 
echo rcl_get_price($post->ID);
?>

            <a href="<?php 
the_permalink();
?>
">
                    <h3 class="title-prod"><?php 
the_title();
?>
</h3>
            </a>

            <div class="product-excerpt">
                    <?php 
rcl_product_excerpt();
Exemplo n.º 3
0
function rcl_slider($atts, $content = null)
{
    rcl_bxslider_scripts();
    extract(shortcode_atts(array('num' => 5, 'term' => '', 'type' => 'post', 'post_meta' => false, 'meta_value' => false, 'tax' => 'category', 'exclude' => false, 'include' => false, 'orderby' => 'post_date', 'title' => true, 'desc' => 280, 'order' => 'DESC', 'size' => '9999,300'), $atts));
    $args = array('numberposts' => $num, 'orderby' => $orderby, 'order' => $order, 'exclude' => $exclude, 'post_type' => $type, 'post_status' => 'publish', 'meta_key' => '_thumbnail_id');
    if ($term) {
        $args['tax_query'] = array(array('taxonomy' => $tax, 'field' => 'id', 'terms' => explode(',', $term)));
    }
    if ($post_meta) {
        $args['meta_query'] = array(array('key' => $post_meta, 'value' => $meta_value));
    }
    //print_r($args);
    $posts = get_posts($args);
    if (!$posts) {
        return false;
    }
    $size = explode(',', $size);
    $size = isset($size[1]) ? $size : $size[0];
    $plslider = '<ul class="slider-rcl">';
    foreach ($posts as $post) {
        //if( !has_post_thumbnail($post->ID)) continue;
        $thumb_id = get_post_thumbnail_id($post->ID);
        $large_url = wp_get_attachment_image_src($thumb_id, 'full');
        $thumb_url = wp_get_attachment_image_src($thumb_id, $size);
        $plslider .= '<li><a href="' . get_permalink($post->ID) . '">';
        if ($type = 'products') {
            $plslider .= rcl_get_price($post->ID);
        }
        $plslider .= '<img src=' . $thumb_url[0] . '>';
        if ($post->post_excerpt) {
            $post_content = strip_tags($post->post_excerpt);
        } else {
            $post_content = apply_filters('the_content', strip_tags($post->post_content));
        }
        if ($desc > 0 && strlen($post_content) > $desc) {
            $post_content = substr($post_content, 0, $desc);
            $post_content = preg_replace('@(.*)\\s[^\\s]*$@s', '\\1 ...', $post_content);
        }
        $plslider .= '<div class="content-slide">';
        if ($title) {
            $plslider .= '<h3>' . $post->post_title . '</h3>';
        }
        if ($desc > 0) {
            $plslider .= '<p>' . $post_content . '</p>';
        }
        $plslider .= '</div>';
        $plslider .= '</a></li>';
    }
    $plslider .= '</ul>';
    return $plslider;
}