Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom post types with custom taxonomies to work as events #248

Open
JiveDig opened this issue Feb 10, 2022 · 1 comment · May be fixed by #255
Open

Allow custom post types with custom taxonomies to work as events #248

JiveDig opened this issue Feb 10, 2022 · 1 comment · May be fixed by #255

Comments

@JiveDig
Copy link

JiveDig commented Feb 10, 2022

Per a discussion with JJJ, this was working at one point but is no longer fully-functional.

A great scenario is using a WooCommerce shop for free/paid events, where the products are the events. This is already working with the following code:

/**
 * Allows WooCommerce Products to work as Sugar Calendar Events.
 * Registers Event Categories to Products.
 *
 * @return void
 */
add_action( 'init', function() {

	// Throws errors.
	// unregister_post_type( 'sc_event' );

	// Enable events on products.
	add_post_type_support( 'product', 'events' );

	// Enable event categories to products.
	register_taxonomy_for_object_type( 'sc_event_category', 'product' );

}, 999 );

This gives us 2 issues:

  1. Custom taxonomy archives (calendars taxonomy, product categories, etc.) all show 0 events/products. The main calendar view does work correctly.
  2. Feeds via the Custom Feeds add-on are all empty. There are no events in them.

After some digging, it looks like the post_type is hard-coded in sugar_calendar_get_event_post_type_id() function. Calendar Feeds add-on uses get_ical_url() function as the core function when generating all feeds, and that function uses sugar_calendar_get_event_post_type_id() to build the feeds from the post type data.

I hard-coded sugar_calendar_get_event_post_type_id() to return product and it didn’t fully work either, though I only tested briefly.

This would be an extremely powerful feature IMO and possibly a nice add-on for full Woo compatibility. It opens a huge door for a powerful paid event management system.

@JJJ
Copy link
Contributor

JJJ commented Feb 10, 2022

Improved admin navigation support here: 5798a18

@JJJ JJJ linked a pull request Mar 9, 2022 that will close this issue
@JJJ JJJ linked a pull request Mar 9, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants