WordPress.org

Ready to get started?Download WordPress

Forums

FoxyShop
[resolved] another foxyshop-single-product template (5 posts)

  1. eddiejanzer
    Member
    Posted 2 years ago #

    I am using foxyshop-single-product.php in my child theme, all works great. I have a category of products that requires a different display (more than css can do). Is it possible to have a another foxyshop-single-product.php template used for another category?

  2. sparkweb
    Member
    Plugin Author

    Posted 2 years ago #

    I would recommend just making another conditional inside of foxyshop-single-product.php.

    Look in helperfunctions.php line 689 for some code for grabbing the current product category. Then...

    if (category == "my-new-fancy-category") :
    show cool new stuff
    else :
    show old boring stuff
    endif;

    You could even do includes out to other pages if you wanted.

    EDIT: It's not exactly line 689. Look around there for this "} elseif ($post->ID) {"

  3. eddiejanzer
    Member
    Posted 2 years ago #

    So, I'm not to sharp on php, and the "if" and "else" are really hard. I did this below, at least the page did not go white, but right now I am just testing the one particular piece (foxyshop_inventory_management) to see when it will work. The category is "pillows", which I want to show up with different info. Maybe you can tweek this?

    if ( 'category' =="pillows") :
    
    	//Check Inventory Levels and Display Status (last variable allows ordering of out of stock items)
    	foxyshop_inventory_management("notice: only %c pillows%s left in stock!", "sorry, item is not in stock.", false);
    
    	else :
    	foxyshop_inventory_management("notice: only %c yard%s left in stock!", "sorry, item is not in stock.", false);
    	endif;
  4. sparkweb
    Member
    Plugin Author

    Posted 2 years ago #

    I wrote some code that grabs the category from the products page. This is what you'll want to do:

    $product_categories = wp_get_post_terms($product['id'], 'foxyshop_categories', array("fields" => "names"));
    
    //Pillows Category
    if (in_array('Pillows', $product_categories)) :
    
    	//Check Inventory Levels and Display Status (last variable allows ordering of out of stock items)
    	foxyshop_inventory_management("notice: only %c pillows%s left in stock!", "sorry, item is not in stock.", false);
    
    //Everything Else
    else :
    
    	foxyshop_inventory_management("notice: only %c yard%s left in stock!", "sorry, item is not in stock.", false);
    
    endif;

    You Could Also Do (just different syntax):

    if (in_array('Pillows', $product_categories)) }
    	.....
    } else {
    
    	........
    }
  5. eddiejanzer
    Member
    Posted 2 years ago #

    wow! Majic. I been waiting for the little email sound my computer makes, letting me know there was something to try. Thanks so much. Works like a charm. I will study it and learn from it,

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags