Add items to a Woocommerce product (a pack) from a cpt

Support General Add items to a Woocommerce product (a pack) from a cpt

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #36357
    Daniele GladichDaniele Gladich
    Participant

    Hi, I'm working on a woocommerce site, with oxygen builder and metabox.
    The products are packs with 4 or 5 different products, and the price is for the pack (single products haven't a visible price and they cannot be bought individually but can be part of several packs).
    I'd like to create a CPT for all single products with all the needed fields (images, description, ...) and then add a cloneable field group in woocommerce product page (the pack) to add single products to the pack so that I can show them in the product page with oxygen repeater in frontend.
    I can create the cpt but I'm struggling to understand how to link the cpt with the woocommerce product page. Have I to use relationships? Thanks for the help!

    #36364
    Long NguyenLong Nguyen
    Moderator

    Hi Daniele,

    It works like the related posts so I think you can use the field post or extension MB Relationships to connect some posts of a CPT to a WooCommerce product and display them on the frontend. But it is very hard to include these posts (pack) in the order and process them in the WooCommerce system.
    I recommend using the group product of WooCommerce or a third-party plugin to create the pack like that.

    #36375
    Daniele GladichDaniele Gladich
    Participant

    Hi Long, thanks for the informations.

    I don't have to include single products (from now "items") in the order and process them in the WooCommerce system. Packs (from now "products") are the one to be processed.
    Every product is made with 4 or 5 items and customers can't change them. So I need only to show items in the product page.

    Example:
    Product name: Fruit
    Fruit has 1 banana, 1 apple, 1 orange

    I've tried both the solutions.

    Relationship works well but if, in the example, Fruit has 2 apples, I can't output that quantity because every item can be part of multiple products and so I can't add a quantity field in the item post.

    Post field would be better. I created a cloneable group field to be shown in woo product page with a post field and a number field for the quantity, but using oxygen repeater (with the meta box group option checked) only the id of the post field is shown (I'd like to output title, description and images). Any idea?

    Thanks
    Daniele

    #36385
    Long NguyenLong Nguyen
    Moderator

    Hi,

    You can use the WordPress function to show the post title, post content, featured images ... based on the post ID. For example: get_the_title()
    https://developer.wordpress.org/reference/functions/get_the_title/

    You can also contact Oxygen support to ask for implementing the code in the repeater.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.