• Resolved urka

    (@urka)


    Hi
    unfortunately your great plugin does not work with my theme TheGem ??
    This is now the 3rd plugin which do not show the meta fields in my theme but the plugin I liked most in backend.
    Would be great if you can help me!

    Sometimes my theme use other field names then standard woocommerce but I insert one fixed custom meta field in cart and chekcout from a hidden field in my product page with this hook.

    
    // save to cart
    function save_custom_data_hidden_field( $cart_item_data, $product_id ) {
        if( isset( $_REQUEST['myVehicle'] ) ) {
            $cart_item_data[ 'myVehicle' ] = $_REQUEST['myVehicle'];
            /* below statement make sure every add to cart action as unique line item */
            $cart_item_data['unique_key'] = md5( microtime().rand() );
        }
        return $cart_item_data;
    }
    add_action( 'woocommerce_add_cart_item_data', 'save_custom_data_hidden_field', 10, 2 );
    
    //Insert to Cart & Checkout Page
    function render_meta_on_cart_and_checkout( $cart_data, $cart_item = null ) {
        $custom_items = array();
     
        if( !empty( $cart_data ) ) {
            $custom_items = $cart_data;
        }
        if( isset( $cart_item['myVehicle'] ) ) {
            $custom_items[] = array( "name" => 'Typ',"value" => $cart_item['myVehicle'] );
        }
        return $custom_items;
    }
    add_filter( 'woocommerce_get_item_data', 'render_meta_on_cart_and_checkout', 10, 2 );
    
Viewing 12 replies - 1 through 12 (of 12 total)
  • N-Media

    (@nmedia)

    Hi @urka,

    well I will try my best to sort this out but it will be better if you can ask your theme developer why this not loading fields, actually we use a standard hooks added by woocommerce. So this theme developer must have removed these hooks and if these hooks are not there we cannot show fields.

    Thread Starter urka

    (@urka)

    Hi,
    if I can find out what they have changed (because I think they have changed a hook), do you think that you can help?
    kind regards

    Thread Starter urka

    (@urka)

    Hi again,
    please can you say me what hook you use to add the fields on the page, then my theme support will help!
    Thank you

    N-Media

    (@nmedia)

    Hi,

    well, I am surprised why this theme developer making such major changes in theme regarding hooks, and it’s not recommended by WooCommerce as well.

    Thread Starter urka

    (@urka)

    Hi,
    I am not surprised I am angry about this.

    Please can you tell me which woocommerce hook you use?
    Then I can write this to my Theme support and hope they will say what is changed on this part.

    I can not change theme at this moment but I am thinking about this really. It is not a free Theme and I made sure that it is WPML and woocommerce compatible before I started with.

    N-Media

    (@nmedia)

    This is hook which should inside your product page:

    woocommerce_add_cart_item_data

    Thread Starter urka

    (@urka)

    thx so lot, hope I’ll get help now from theme support

    N-Media

    (@nmedia)

    Cheers.

    I wish I can help you but theme messed up all ??

    Thread Starter urka

    (@urka)

    Thanks for your help but I am on the same issue as before ??

    My Theme Support gives me the following code for function.php which should fix it

    function thegem_woocommerce_add_cart_item_data() {
    add_action('thegem_woocommerce_single_product_right', 'woocommerce_add_cart_item_data', 20);
    }
    add_action( 'init', 'thegem_woocommerce_add_cart_item_data');

    But I still have no fields in my product page shown. I also have an empty checkout if I activate your plugin and get Error
    Fatal error: Uncaught Error: Call to a member function get_meta_data() on array in /home/.sites/74/site3501189/web/stage2/wp-content/plugins/woocommerce-product-addon/inc/woocommerce.php:801 Stack trace:

    Answer from TheGem support is:
    Hi,
    by this action you can add this hook to the page. About the plugin, sorry, we don’t provide support with the third-party plugins, pls. be so kind to understand that we can’t to check on the compatibility with the theme tons of the plugins and it’s updates.

    I can not beliefe ?? I need urgent for custom fields in product page and now it seems i can change theme and have a lot of work and test again before I can do what I have to do. That is very bad for our young company.

    If you have any Idea please let me know.

    N-Media

    (@nmedia)

    Hi,

    well about the error, it seems you have older version of WooCommerce as well, please update to latest WooCommerce.

    Thread Starter urka

    (@urka)

    I have installed Woocommerce 3.5.6

    N-Media

    (@nmedia)

    Sorry, I tried my best to make it fix but it’s a theme issue. They have removed core hook from product page which is very strange. They have to correct it in order to work with WooCommerce other plugins as well.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘fields are not shown in my theme’ is closed to new replies.