Tips and Tricks HQ Support

Support site for Tips and Tricks HQ premium products

  • Home
  • Contact Us
  • Documentation
  • Forum Home
    • Forum
    • Forum Search
    • Forum Login
    • Forum Registration

Fancy 1 without Thumbs or Price

by

Tips and Tricks HQ Support Portal › Forums › WP eStore Forum › Fancy 1 without Thumbs or Price

Tagged: Custom Shortcode, fancy1, no price, no thumb, no thumbnail, shortcode

  • This topic has 4 replies, 1 voice, and was last updated 11 years, 11 months ago by FireSamurai.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • April 14, 2011 at 12:09 am #3179
    FireSamurai
    Member

    Is there a way to not display either price or thumbnail using this shortcode:

    [wp_eStore_fancy1_no_price id=#]

    If not, can you point me in the right direction to do so?

    Thanks,

    FS

    April 14, 2011 at 12:24 am #31307
    FireSamurai
    Member

    Would it be easier to remove the thumb from

    [wp_eStore_fancy1_no_price id=#]

    or to remove the price from

    [wp_eStore_fancy1_no_thumbnail id=#] ?

    or to combine the two into a new shortcode?

    Thanks again,

    FS

    April 14, 2011 at 7:52 am #31308
    FireSamurai
    Member

    I had a 1:00 a.m. epiphany of how to do this, so I hopped out of bed and pounded out a sweet lil’ shortcode. I’ll post my solution tomorrow once I’ve got it all styled up nice.

    Peace, and good night!

    April 14, 2011 at 11:38 pm #31309
    FireSamurai
    Member

    Okay, here it is. This is actually a custom shortcode that provides all the stuff I needed for a particular item type.

    [product id=1 type=1] : Display Product ID 1 with Add to Cart button

    [product id=1 type=2] : Display Product ID 1 with Buy Now button

    [product id=1 type=3] : Display Product ID 1 with Subscribe button

    [product id=1 type=4] : Display Product ID 1 with Download button

    It looks for the following (listed in no particular order):

    * A generic image

    * Product ID

    * Product description

    * Sale price

    * Regular price

    * Button type

    * Quantity available

    * Quantity field

    CSS shown after the shortcode’s code.

    /*

    * DISPLAY INDIVIDUAL PRODUCTS WITH CUSTOM LAYOUT

    *

    * @author Chris Mower (borrowing heavily on the core functionality and hard work done by Tips & Tricks HQ)

    * @link http://www.chrismower.com

    * @link http://www.tipsandtricks-hq.com

    */

    // Adds the shortcode

    add_shortcode('product', 'cm_display_product');

    function cm_display_product($atts){

    extract(shortcode_atts(array(

    'id' => 'no id',

    'type' => '1',

    ), $atts));

    return cm_display_product_guts($id,$type);

    }

    // Functionality behind the shortcode

    function cm_display_product_guts($id,$button_type=1) {

    global $wpdb;

    $products_table_name = WP_ESTORE_PRODUCTS_TABLE_NAME;

    $ret_product = $wpdb->get_row("SELECT * FROM $products_table_name WHERE id = '$id'", OBJECT);

    $imageName = 'image.png';

    $imagePath = '<img src="YOUR IMAGE URL HERE/'.$imageName.'" />'; // Add universal image here

    $output = '<div class="product-box">';

    // Display a generic image

    $output .= '<div class="product-img">'.$imagePath.'</div><!-- end .product-img -->';

    $output .= '<div class="product">';

    // Show product name with link to product URL

    $output .= '<div class="product-name">product_url.'">'.$ret_product->name.'</div>';

    // Display product description if field is populated

    if(!empty($ret_product->description)){

    $output .= '<div class="product-description">'.html_entity_decode($ret_product->description, ENT_COMPAT,"UTF-8").'</div><!-- end .product-description -->';

    }

    // Display available copies if field is populated

    if (!empty($ret_product->available_copies))

    $output .= '<div class="product-qty"><span id="qty-text">'.ESTORE_AVAILABLE_QTY.': </span>'.$ret_product->available_copies.'</div><!-- end .product-qty -->';

    $output .= '<div class="prices-container">';

    // Display original (old) price if field is populated

    if(!empty($ret_product->old_price)){

    $output .= '<div class="product-old-price"><span id="old-price-text">'.ESTORE_OLD_PRICE.': </span>'.WP_ESTORE_CURRENCY_SYMBOL.$ret_product->old_price.'</div><!-- end .product-old-price -->';

    }

    // Display product price if field is not equal to 0

    if($ret_product->price != 0) {

    $output .= '<div class="product-price"><span id="price-text">'.ESTORE_PRICE.': </span>'.print_digi_cart_payment_currency($ret_product->price, WP_ESTORE_CURRENCY_SYMBOL, ".").'</div><!-- end .product-price -->';

    }

    $output .= '</div><!-- end .prices-container -->';

    // Display different button types

    $output .= '<div class="product-button">';

    if($button_type == 1)

    {

    // Add to Cart

    $output .= get_button_code_for_element($ret_product, false);

    }

    else if ($button_type == 2)

    {

    // Buy Now

    $output .= print_eStore_buy_now_button($id);

    }

    else if ($button_type == 3)

    {

    // Subscribe

    $output .= print_eStore_subscribe_button_form($id);

    }

    else if ($button_type == 4)

    {

    // Download

    $output .= eStore_show_download_now_button($id);

    }

    $output .= '</div><!-- end .product-button -->';

    $output .= '</div><!-- end .product -->';

    $output .= '</div><!-- end .product-box -->';

    return $output;

    }


    Here is the CSS I used to style it:

    /* Individual Product Styles */

    .product-box {

    border-bottom-color:#cccccc9; /* IE8 and below */

    border-bottom-style:dashed9; /* IE8 and below */

    border-bottom-width:1px9; /* IE8 and below */

    -moz-box-shadow:0 0 3px 1px rgba(3, 101, 191, 1);

    -khtml-box-shadow:0 0 3px 1px rgba(3, 101, 191, 1);

    -webkit-box-shadow:0 0 3px 1px rgba(3, 101, 191, 1);

    box-shadow:0 0 3px 1px rgba(3, 101, 191, 1);

    font-size:14px;

    margin:20px 0 0;

    padding:0;

    overflow:hidden;

    }

    .product-img {

    border:none;

    float:left;

    height:50px;

    width:50px;

    margin:10px;

    padding:0;

    }

    .product {

    padding:10px 10px 10px 75px;

    margin:0;

    }

    .product-name {

    background:none;

    border-bottom:1px dotted #bbbbbb;

    font-size:16px;

    font-weight:500;

    margin:0 0 5px;

    padding:0 0 5px 0;

    }

    .product-description {

    margin:2px 0;

    }

    .product-qty {

    font-style:italic;

    float:right;

    }

    #qty-text { }

    .prices-container {

    font-weight:bold;

    margin:2px 0;

    overflow:hidden;

    }

    .product-price {

    float:left;

    font-size:14px;

    margin:2px 0;

    }

    #price-text { }

    .product-old-price {

    color:red;

    float:left;

    font-style:italic;

    margin:2px 10px 2px 0;

    padding:0;

    text-decoration:line-through;

    }

    #old-price-text { }

    .product-button {

    margin:0 0 10px;

    padding:0;

    }

    .product-box .eStore-button-form { }

    .product-box .eStore_variation { /* variation drop-down */

    margin:0 20px 3px 2px;

    }

    .product-box .eStore-button-form input[type="text"] { /* quantity box */

    margin:3px 15px 3px 2px;

    }

    .product-box input.eStore_button { /* Add to Cart, etc. button */

    margin:3px 0 10px 2px;

    float:right;

    }


    But… after all that was said and done, I realized I needed a category shortcode to also display that same style… so to do that I created another shortcode for categories. So, here it is…

    [pcat id=2 type=1 order=1] : Displays all products in category 2, uses Add to Cart button, orders by product ID ascending

    [pcat id=2 type=1 order=1 number=4] : Displays all products in category 2, uses Add to Cart button, orders by product ID ascending, limits products per page to 4

    Keep in mind that the usual button types and order structures provided by Tips & Tricks HQ works within this shortcode. The first shortcode example doesn’t use the number parameter. You can leave it out and it will default to whatever the products-per-page setting is in the Admin Panel’s General Settings.

    Here’s the code (CSS shown after).

    /*

    * DISPLAY CATEGORIES WITH CUSTOM LAYOUT

    *

    * @author Chris Mower (borrowing heavily on the core functionality and hard work done by Tips & Tricks HQ)

    * @link http://www.chrismower.com

    * @link http://www.tipsandtricks-hq.com

    */

    //Adds the shortcode

    add_shortcode('pcat', 'cm_display_category');

    function cm_display_category($atts){

    extract(shortcode_atts(array(

    'id' => 'no id', // defaults to no category ID specified

    'order' => '1', // defaults to order by product ID ascending

    'type' => '1', // defaults to 'add to cart'

    'number' => '0', // defaults to products-per-page setting

    ), $atts));

    return cm_display_category_guts($id,$order,$type,$number);

    }

    // Functionality behind the shortcode

    function cm_display_category_guts($id,$order=1,$button_type=1,$number=0)

    {

    // Checks id attribute to see if it's set in the shortcode

    if($id == 'no id')

    {

    return '<div class="cat-no-id-text">Oops! You did not specify a category ID. Please enter a category ID with this shortcode.</div><!-- end .cat-no-id-text -->';

    }

    // Checks to see if number is specified in shortcode, if not specified, adds pagination with these rules

    if($number == 0)

    {

    $i = 0;

    // Set pages to include $limit records per page

    $limit = get_option('eStore_products_per_page');

    // If the products-per-page setting is empty, use this limit

    if(empty($limit))

    {

    $limit = 9999; // Set new limit here

    }

    // If products-per-page setting is populated, create product pages

    if (isset($_GET))

    {

    $page = $_GET;

    }

    // If no product pages are set stay on page 1

    else

    {

    $page = 1;

    }

    $start = ($page - 1) * $limit;

    }

    // If shortcode specifies a number, limit entries to that number

    else{

    $start = 0;

    $limit = $number;

    }

    global $wpdb;

    $cat_prod_rel_table_name = $wpdb->prefix . "wp_eStore_cat_prod_rel_tbl";

    $products_table_name = WP_ESTORE_PRODUCTS_TABLE_NAME;

    // Sort by product ID ascending

    if($order == 1)

    {

    $wp_eStore_db = $wpdb->get_results("SELECT * FROM $cat_prod_rel_table_name where cat_id=$id LIMIT $start, $limit", OBJECT);

    }

    // Sort by product ID descending

    else if($order == 2)

    {

    $wp_eStore_db = $wpdb->get_results("SELECT * FROM $cat_prod_rel_table_name where cat_id=$id ORDER BY prod_id DESC LIMIT $start, $limit", OBJECT);

    }

    // Sort by product name ascending

    else if($order == 3)

    {

    $wp_eStore_db = $wpdb->get_results("SELECT * FROM $cat_prod_rel_table_name INNER JOIN $products_table_name ON $cat_prod_rel_table_name.prod_id=$products_table_name.id where cat_id=$id ORDER BY name LIMIT $start, $limit", OBJECT);

    }

    // Sort by product name descending

    else if($order == 4)

    {

    $wp_eStore_db = $wpdb->get_results("SELECT * FROM $cat_prod_rel_table_name INNER JOIN $products_table_name ON $cat_prod_rel_table_name.prod_id=$products_table_name.id where cat_id=$id ORDER BY name DESC LIMIT $start, $limit", OBJECT);

    }

    // Sort by available copies ascending

    else if($order == 5)

    {

    $wp_eStore_db = $wpdb->get_results("SELECT * FROM $cat_prod_rel_table_name INNER JOIN $products_table_name ON $cat_prod_rel_table_name.prod_id=$products_table_name.id where cat_id=$id ORDER BY available_copies LIMIT $start, $limit", OBJECT);

    }

    // Sort by available copies descending

    else if($order == 6)

    {

    $wp_eStore_db = $wpdb->get_results("SELECT * FROM $cat_prod_rel_table_name INNER JOIN $products_table_name ON $cat_prod_rel_table_name.prod_id=$products_table_name.id where cat_id=$id ORDER BY available_copies DESC LIMIT $start, $limit", OBJECT);

    }

    // Sort by price ascending

    else if($order == 7)

    {

    $wp_eStore_db = $wpdb->get_results("SELECT * FROM $cat_prod_rel_table_name INNER JOIN $products_table_name ON $cat_prod_rel_table_name.prod_id=$products_table_name.id where cat_id=$id ORDER BY price LIMIT $start, $limit", OBJECT);

    }

    // Sort by price descending

    else if($order == 8)

    {

    $wp_eStore_db = $wpdb->get_results("SELECT * FROM $cat_prod_rel_table_name INNER JOIN $products_table_name ON $cat_prod_rel_table_name.prod_id=$products_table_name.id where cat_id=$id ORDER BY price DESC LIMIT $start, $limit", OBJECT);

    }

    $totalrows = $wpdb->get_var("SELECT COUNT(*) FROM $cat_prod_rel_table_name where cat_id=$id;");

    // Display products using custom layout

    if ($wp_eStore_db)

    {

    foreach ($wp_eStore_db as $wp_eStore_db)

    {

    $output .= cm_display_product_guts($wp_eStore_db->prod_id,$button_type);

    }

    }

    else

    {

    $output .= '<div class="cat-no-products-text">There are no products to display in this category</div><!-- end .cat-no-products-text -->';

    }

    //Clear the float

    $output .= '<div class="eStore-fancy-clear"></div><!-- end .eStore-fancy-clear -->';

    // Checks to see if there are more database entries than to what the limit is set

    if ($totalrows > $limit && $number == 0)

    {

    // Determines how many pages to display

    $pages = ceil($totalrows / $limit)+1;

    $separator = '?'; // Default permalink & product page separator

    $url = get_permalink();

    $pagesText = 'Product Pages: ';

    // Sets appropriate URL separator depending on what's found in the permalink

    if(strpos($url,'product_page=')) // Removed ? from '?product_page='. We want to first check if the string 'product_page=' exists, and then add '?' to it instead of checking for '?product_page=' and then adding another '?' to it.

    {

    $separator = '?';

    }

    else if(strpos($url,'?') !== false)

    {

    $separator = '&'; // Creates proper URL string

    }

    $output .= '<div class="cat-page-tabs-container">';

    $output .= '<div id="cat-pages-text">'.$pagesText.'</div>';

    for($r = 1;$r<$pages;$r++) // Starts pagination at 1 and loops

    {

    $output .= '<div id="cat-page-tabs">'.$r.'</div><!-- end #cat-page-tabs -->';

    // Once the remainder of pages reaches zero, ouput some breaks

    if ($r%15 == 0)

    {

    $output .= '

    ';

    }

    }

    $output .= '</div><!-- end .cat-page-tabs-container -->';

    }

    return $output;

    }


    And of course, that needs to be styled, so here is the CSS I used.

    /* List Product Category Styles with Custom Product Structure */

    .cat-no-id-text, .cat-no-products-text {

    color:#000000;

    font-style:italic;

    }

    .cat-page-tabs-container {

    background:transparent;

    margin:5px 0 15px;

    padding:5px;

    overflow:hidden;

    clear:both;

    }

    #cat-pages-text {

    float:left;

    margin:2px 0 0;

    }

    #cat-page-tabs {

    background:#f0f0f0;

    border:1px solid #000000;

    margin:0 0 0 5px;

    padding:1px 7px 2px;

    float:left;

    }

    Well, for whoever comes across this, hope it helps.

    Cheers!

    FS

    April 14, 2011 at 11:53 pm #31310
    FireSamurai
    Member

    One area that seems to work, but I’m not sure if I did it right, is in the categories shortcode,

    if(strpos($url,'product_page=')) // Removed ? from '?product_page='. We want to first check if the string 'product_page=' exists, and then add '?' to it instead of checking for '?product_page=' and then adding another '?' to it.

    I removed a ? from before product_page=. My reasoning is explained in the commented out text… is that reasoning correct?

    Also in the category code above, 8 lines up from the end, there is a section that looks like this:

    $output .= '

    ';

    There are two line breaks in that, but the forum interprets them as actual line breaks. It should look like this:

    $output .= '<br /><br />';

    Hope that helps.

    FS

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Log In

Forum Related

  • Forum Home
  • Forum Search
  • Forum Login

Support Related Forms

  • Contact Us
  • Customer Support
  • Request a Plugin Update
  • Request Fresh Download Links

Useful Links

  • Plugin Upgrade Instructions
  • WP eStore Documentation
  • WP eMember Documentation
  • WP Affiliate Platform Documentation
  • WP PDF Stamper Documentation
  • WP Photo Seller Documentation
  • Tips and Tricks HQ Home Page
  • Our Projects

Quick Setup Video Tutorials

  • WP eStore Video Tutorial
  • WP eMember Video Tutorial
  • WP Affiliate Platform Video Tutorial
  • Lightbox Ultimate Video Tutorial
  • WP Photo Seller Video Tutorial

Our Other Plugins

  • WP Express Checkout
  • Stripe Payments Plugin
  • Simple Shopping Cart Plugin
  • Simple Download Monitor

Copyright © 2023 | Tips and Tricks HQ