• So I’ve made a custom product type for woocommerce like explained here
    My problem now lays that i made extra product tabs with some custom field and i want the user to see those custom fields(let him insert his own values) on the front-end(shop). But at this moment i haven’t found a way on how to create a template for a custom product type.

    https://www.ads-software.com/plugins/woocommerce/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Mike Jolley

    (@mikejolley)

    You’d create a new ‘add to cart’ template for your product type. Create a function named woocommerce_YOURTYPE_add_to_cart() and load HTML or a template there to handle it.

    Thread Starter MathF

    (@mathf)

    @mike Jolley first of thanks for your response but could provide a small code/plugin example that i could go off from (so i can understand it better) as the explanation you’ve given me is rather minimal and i’m by far an expert ??

    Plugin Contributor Mike Jolley

    (@mikejolley)

    I can only point you in the correct direction, not provide code. If you need someone to write it for you, consider jobs.wordpress.net.

    Try creating a function like I mentioned. If you can get a custom template started, you should be able to start adding your own fields, and you can base it on our code.

    https://github.com/woothemes/woocommerce/tree/master/templates/single-product/add-to-cart

    Thread Starter MathF

    (@mathf)

    First off before i continue i do have to say i’m making a plugin and not a theme (as these things seem to be vastly different).

    I already created that function as you said (had found that before but it doesn’t really change anything or i’m doing something wrong)

    function woocommerce_mytype_add_to_cart() {
            wc_get_template( WP_PLUGIN_DIR.'/mypluginname/templates/mytype.php' );
    }

    I also have my template, but don’t I miss a certain hook or… that lets woocommerce know that it should load my template instead of the standard product template
    Also mytype’s extends WC_Product and not WC_Simple_Product (don’t know if it matters for this)

    Plugin Contributor Mike Jolley

    (@mikejolley)

    We are talking about single product pages right?

    https://github.com/woothemes/woocommerce/blob/master/includes/wc-template-functions.php#L927

    That shows where a custom action is used. So you’re just missing:

    add_action( 'woocommerce_mytype_add_to_cart', 'woocommerce_mytype_add_to_cart' );
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to add/create Woocommerce Custom Product Type "template"’ is closed to new replies.