Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I use wp-e-commerce. I created a custom post type called "event". I would like to create new "event" as a parent and hook products under it. When I "hook" a product under post parent "event", wp-e-commenrce does not appear me this in products at the admin panel. The product exists on database and it's register. The only way to make this product visible is to set the value 0 to "post_parent" field on wp_post table. Wp-e-commerce by default give 0 to post_parent.

function createProduct($event_id, $attach_id, $attach)
        {
            // Create product object
            $product_name = get_the_title($event_id).'_'.$attach_id;
            $evman_product = array(
            'post_title'    => $product_name,
            'post_status'   => 'publish',
            'post_author'   => 1,
            'post_type'     => 'wpsc-product',
            'post_parent'   => $event_id
            );

            // Insert the post into the database
            $this->unhookFromSavePost(); // see http://codex.wordpress.org/Plugin_API/Action_Reference/save_post#Avoiding_infinite_loops
            $evman_the_product_id = wp_insert_post( $evman_product ); //get product's id 
            $this->hookToSavePost();
            //Re-attach attachment to new product
            $attach_duplicated = $attach;
            $attach_duplicated->post_parent = $evman_the_product_id;            
            $newAddedAttachment = wp_insert_attachment( $attach_dublicated );
            return evman_the_product_id;
        }
share|improve this question
    
Why not make registrations a variation of an event product instead of trying to introduce a hierarchy the system wasn't designed for? –  Andrew Bartel Jan 20 at 21:50
    
I want to leave the user to create an "event", upload the images of the product from media and wordpress make the product. Then I go to the event and see the products of the event. –  thanassis Jan 20 at 22:54
    
@AndrewBartel Can I use variation instead of event (custom post type)? –  thanassis Jan 20 at 23:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.