function __construct($productArray, $limit = null)
 {
     if ($limit !== null) {
         $productArray = ostk_limitArrayCount($productArray, $limit);
     }
     foreach ($productArray as $product) {
         $item = new SingleProductData($product);
         if ($item->validProductID) {
             array_push($this->productList, $item);
         } else {
             array_push($this->invalidProductIDs, $product);
             $allValidProductIDs = False;
         }
     }
     //foreach
 }
/**
 * Pattern 5 - Skyscraper: Lets you create a skyscraper banner for up to three products
 * Usage Example
 * 1) [overstock type="skyscraper" product_ids="8641092"]
 * 2) [overstock type="skyscraper" product_ids="8641092, 9547029"]
 * 3) [overstock type="skyscraper" product_ids="8641092, 9547029, 9547023"]
**/
function ostk_generateSkyscraperWidget($atts)
{
    $atts = shortcode_atts(array('product_ids' => null, 'width' => null, 'link_target' => 'new_tab'), $atts);
    $product_ids = isset($atts['product_ids']) ? array_map('trim', explode(',', $atts['product_ids'])) : null;
    foreach ($product_ids as $ids) {
        if (ostk_checkForMissingCommas($id) == true) {
            return ostk_formatError("Commas missing between ids, return ing...");
        }
    }
    //foreach
    $product_ids = ostk_limitArrayCount($product_ids, 3);
    $products = new MultiProductDataFromArray($product_ids);
    if ($products->isAllValidProductIDs()) {
        $output = ostk_generateSkyscraperHtmlOutput($products, $atts);
        $output2 = '<div class="ostk-element ostk-skyscraper" ' . ostk_getStyles($atts) . '>';
        $output2 .= ostk_getBranding();
        $output2 .= $output;
        $output2 .= '</div>';
        return $output2;
    }
}
Ejemplo n.º 3
0
function ostk_generateCarouselHTML($carousel_type, $obj, $atts)
{
    if ($carousel_type == 'carousel') {
        $productList = $obj;
    } else {
        if ($carousel_type == 'product_carousel') {
            $product = $obj;
            $productList = $product->getArrayOfAllProductImages();
        }
    }
    if ($atts['number_of_items'] !== null) {
        $productList = ostk_limitArrayCount($productList, $atts['number_of_items']);
    }
    $output .= '<div class="ostk-flexslider">';
    $output .= '<ul class="slides">';
    if ($carousel_type == 'carousel') {
        foreach ($productList as $product) {
            $productImg = $product->getImage_Large();
            $output .= ostk_getCarouselListItems($product, $productImg, $atts);
        }
        //foreach
    } else {
        if ($carousel_type == 'product_carousel') {
            foreach ($productList as $productImg) {
                $output .= ostk_getCarouselListItems($product, $productImg, $atts);
            }
            //foreach
        }
    }
    $output .= '</ul>';
    $output .= '</div>';
    if (count($productList) > 1) {
        //only show thumbnail navigation if more than 1 item
        $output .= '<div class="custom-navigation">';
        $output .= '<a href="#" class="flex-prev">';
        $output .= '<div class="ostk-arrow ostk-arrow-left"></div>';
        $output .= '</a>';
        $output .= '<a href="#" class="flex-next">';
        $output .= '<div class="ostk-arrow  ostk-arrow-right"></div>';
        $output .= '</a>';
        $output .= '<div class="custom-controls-container"></div>';
        $output .= '</div>';
    }
    return $output;
}