/** * Pattern 8 - Product Details Link * Allow users to create easy links to products they are showcasing. * Example Usage: * 1) [overstock type="product_link" id="8859234"] **/ function ostk_generateProductLinks($atts) { $atts = shortcode_atts(array('id' => null, 'display' => null, 'link_target' => 'new_tab'), $atts); $item = new SingleProductData($atts['id']); if ($item->isValidProductID()) { $display = trim($atts['display']); $output; switch ($display) { case 'name': $output = $item->getName(); break; case "price": $output = $item->getPrice(); break; case 'description': $output = $item->getDescription(); break; default: return ostk_formatError('We do not recognize your display input, please check it.'); } //switch return '<a href="' . $item->getAffiliateUrl() . '" class="ostk-element ostk-product-link" ' . ostk_getLinkTarget($atts) . '>' . $output . '</a>'; } }
function ostk_getCarouselListItems($product, $productImg, $atts) { $output; $output .= '<li data-thumb="' . $productImg . '">'; $output .= '<a href="' . $product->getAffiliateUrl() . '" ' . ostk_getLinkTarget($atts) . '>'; $output .= '<div class="element-content">'; $output .= '<img src="' . $productImg . '"/>'; $output .= '</div>'; $output .= '<div class="element-overlay">'; $output .= '<p class="title">' . $product->getName() . '</p>'; if ($product->averageReviewAsGif) { $output .= '<img class="ostk-rating" src="' . $product->getAverageReviewAsGif() . '"/>'; } $output .= '<p class="price">' . $product->getPrice() . '</p>'; $output .= '<img class="ostk-logo" src="' . plugin_dir_url(__FILE__) . 'images/overstock-logo.png">'; $output .= '</div>'; $output .= '</a>'; $output .= '</li>'; return $output; }