Jump to content

Archived

This topic is now archived and is closed to further replies.

gabelloyd

Flipper for Custom Post Types

Recommended Posts

gabelloyd    4
gabelloyd

http://paste.pagelines.com/JXmB1ORq

 

This applies for WooCommerce, but also for any custom_post_type. 

 

In Flipper, the default allows us to choose a post_type.  Flipper does this by get_post_types, creates and array and then makes that array available to us in the drop down selection.  Let's say I want to set the post type, and then create the array of the taxonomy(ies) under that post type.  My drop down menu would then be populated with the taxonomy(ies) of this specific post type that I've set in my new section file.  

 

Now that we know what I want to do...

 

The documentation for "Select Taxonomy" (ref:  http://docs.pagelines.com/developer/dms-option-engine ) states:

"To create an option that allows users to select a taxonomy (i.e. category) for a specific post type, just use these attributes:"

 

and shows: 

$opts[] = array(
            'key'           => 'some_key',
            'type'          => 'select_taxonomy',
            'post_type'     => 'post' // the post type to grab taxonomies from
        );

Now that we've set that background up:  what is the "key" here?  Is the key my post_type or do I set the key somewhere else?  The default is set to "flipper_post_type".  

 

I've posted an attempt in pastebin above.  

 

Thanks in advance.

Share this post


Link to post
Share on other sites
gabelloyd    4
gabelloyd

Yeah, but I'd rather not have to require the client to enter meta data for every custom post type.  If I set the post_type and know the taxonomy(ies) and slug(s) that I would like to show in the drop down, I should be able to create a new Flipper section, right?  Again, set the product so that the drop down becomes the available taxonomies or slugs.

 

Do I need to change the "key" element?  It's set to "flipper_post_type" in the default, so does this change or remain the same when creating new sections?

 

Thanks!

Share this post


Link to post
Share on other sites
gabelloyd    4
gabelloyd

I did try the shortcodes in the Flipper Meta section, just to see if I could specify the product category that I'm trying to target, but it didn't seem to work.  The I assume I can use the shortcodes from WooCommerce for this?

 

So, back to the dropdown of sub-catgeories in a custom Flipper Section, I just wanted to check to make sure I'm focusing on the right area of the functions here.  

 

Reference of terms that we are working with here:

 

(from URL string:  taxonomy=product_cat&tag_ID=55&post_type=product)

custom_post_type  = product

taxonomy = product_cat

slug = (determined by drop down selection, but looking here for 'certified' or term_ID of 55)  (which is the KEY that I was asking about earlier)

 

In my custom flipper section, this works: 

if($this->opt('flipper_post_type') == 'post'){
			$selection_opts[] = array(
				'label'			=> 'Post Category',
				'key'			=> 'flipper_category', 
				'type'			=> 'select_taxonomy', 
				'post_type'		=> 'post', 
				'help'		=> __( 'Only applies for standard blog posts.', 'pagelines' ),
			); 
		}
		
		elseif ($this->opt('flipper_post_type') == 'product') {
			$selection_opts[] = array(
				'label'			=> 'Product Category',
				'key'			=> 'flipper_category', 
				'type'			=> 'select_taxonomy', 
				'post_type'		=> 'product', 
				'help'		=> __( 'Only applies for products.', 'pagelines' ),
			); 

		}

It seems that farther down the file, the actual execution of the function takes place.  I've been unable to get the dropdown to display the sub-categories of the products.  Most recently I've referenced these articles to help, but to no avail:

 

How we would create a custom_post_type dropdown menu without Pagelines:  http://wordpress.stackexchange.com/questions/1236/custom-post-type-taxonomy-dropdown-menu

<?php $tax = get_object_taxonomies('TAXONOMY_NAME');
$taxterms = get_terms( $tax, 'orderby=count&offset=1&hide_empty=0&fields=all' );
?>

foreach ( $taxterms as $term ) { 
        echo '<option value="' . $term->slug . '" selected>' . $term->name . '</option>',"\n"; 
    } ?>

Checking difference between is_product_category and in_product_category (you can use 'has_term') http://wordpress.org/support/topic/plugin-woocommerce-excelling-ecommerce-is_product_category-vs-in_product_category?replies=4

Stackexchange for getting top level parent for WooComm:  http://wordpress.stackexchange.com/questions/24794/get-the-the-top-level-parent-of-a-custom-taxonomy-term

WooCommerce is_product: http://docs.woothemes.com/wc-apidocs/function-is_product_category.html

And I checked out Ellen's WooCommerce for Pagelines sections:  https://github.com/bearded-avenger/pagelines-woocommerce/blob/master/pagelines-woocommerce.php to see how she's calling product information. 

 

 

Just to be clear, the Products DO SHOW, but I want to filter the Products by category and allow the client to have this filtering ability.  

 

I know the function for regular post filtering is this:

if ('flipper_post_type' == 'post') {
		
		if( $this->opt('flipper_category') && $this->opt('flipper_category') != '' ){
			$cat = get_category_by_slug( $this->opt('flipper_category') ); 
			$the_query['category'] = $cat->term_id;
		}

but when I do something like this, it doesn't work:

}  elseif ('flipper_post_type' == 'product') {

		if( $this->opt('flipper_category') && $this->opt('flipper_category') != '' ){
			
			$term = has_term( 'flipper_category', 'product_cat' );
			
			$the_query['category'] = $term->term_id;
			
			}
		}

Thanks for any help.

Share this post


Link to post
Share on other sites

  • Similar Content

    • hibbsy78
      By hibbsy78+
      Anyone having issues with Apple Pay & woocommerce? Before I start with trying to disable plugins one by one I thought I'd check here first!
      I'm having issues with the payment processing part which just times out?
      https://www.hibbslupustrust.org/shop/
       
      Thanks!
    • Paul
      By Paul+
      I have woocommerce store, product shows title and price fine until reduce screen with on a tablet/mobile phone the price and title gets removed?  Any ideas? 
      Here's an example page: https://thelaptopfixers.com/product/operating-system-re-install/
      Try it on both desktop PC browser then resize to mobile/cell phone size!  
      Thanks
    • ProCom
      By ProCom+
      I am trying to resolve a few issues. The first one is when I have the Platform 5 activated the product image will not display. However, once I deactivate the plugin the image will appear.  Can someone tell me if there is a article on how to customize the WooCommerce product, and shop pages using PageLines? 
       
       

    • dreamsight
      By dreamsight+
      We only want the images and title mouse-over, not link/click to the actual post the title is from.
      Any ideas anyone?
      Thanks
    • BentleyD
      By BentleyD+
      Hey Everyone,
       
      Ever since the latest wordpress update, woocommerce will not display the product images. When you click where they should be they pop up in a light box, but otherwise are not visible. The errors appear to be theme related. Is there an update or fix for this?
       
      http://legalizedshop.com/product/legalized-t-shirt/
      @James B @batman
×