• Resolved eddiejanzer

    (@eddiejanzer)


    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?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author sparkweb

    (@sparkweb)

    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) {”

    Thread Starter eddiejanzer

    (@eddiejanzer)

    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;

    Plugin Author sparkweb

    (@sparkweb)

    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 {
    
    	........
    }
    Thread Starter eddiejanzer

    (@eddiejanzer)

    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,

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘another foxyshop-single-product template’ is closed to new replies.