Trying to change value of Post Type

Ediboy

20 Feb, 2013 12:31 PM

Hi,

Good day. I'm trying to create frontend add product in jigoshop. Im having problem updating the Product Type. I was able to change the value of other meta box dropdown like Stock status and Customize Product but no luck in Product type. Please see below.

update_post_meta($post_id, 'product-type', 'variable'); --> This doesn't work
update_post_meta($post_id, 'product_customize', 'yes'); --> works
update_post_meta($post_id, 'stock_status', 'instock'); --> works

Hope someone can help me.

Thank you.

  1. Support Staff 2 Posted by chriscct7 on 20 Feb, 2013 01:37 PM

    chriscct7's Avatar

    Are you in The Loop, or outside The Loop?
    We're gonna need to see alot more of your code than that ^

  2. 3 Posted by Ediboy on 21 Feb, 2013 03:34 AM

    Thank you for your reply.

    I'm calling this outside the loop. This is called after I just added a new product frontend.

    Here is the code that created the dropdown meta that I'm trying update found in product-data.php

    Failed to update using update_post_meta
    <?php
    $terms = get_the_terms( $thepostid, 'product_type' ); $product_type = ($terms) ? current($terms)->slug : 'simple';

    $args = array( 'id' => 'product-type', 'label' => __('Product Type', 'jigoshop'), 'options' => apply_filters( 'jigoshop_product_type_selector', array( 'simple' => __('Simple', 'jigoshop'), 'downloadable' => __('Downloadable', 'jigoshop'), 'grouped' => __('Grouped', 'jigoshop'), 'virtual' => __('Virtual', 'jigoshop'), 'variable' => __('Variable', 'jigoshop'), 'external' => __('External / Affiliate', 'jigoshop') )), 'selected' => $product_type, ); echo Jigoshop_Forms::select( $args );

    ?>

    Success to update using update_post_meta
    <?php
    $args = array( 'id' => 'stock_status', 'label' => __( 'Stock Status', 'jigoshop' ), 'options' => array( 'instock' => __('In Stock','jigoshop'), 'outofstock' => __('Out of Stock','jigoshop') ) ); echo Jigoshop_Forms::select( $args );
    ?>

    It's because of the "'selected' => $product_type," setting it to 'simple' but is there a way that I can hook this? I wanted it to be variable but I don't want to hardcode it for future expansion.

    Thank you in advance.

Reply to this discussion

Internal reply

Formatting help or Preview

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.