Okay
  Public Ticket #3363143
Accessing the vendor object / data
Closed

Comments

  • John started the conversation

    Hi,

    In your technical docs, you show examples of how to access vendor data on page templates.  I am focusing on the product page templates currently. For example...

    echo marketking()->get_store_name_display($vendor_id);

    The example above breaks the page (causes php error) on its own. There is no value for $vendor_id without some sort of context defined. Can you give a full example of how to initialize the data so we can access the  marketking() object? Also, how would I get $vendor_id? Another important field to retrieve are the vendor's terms and conditions.

    Thanks!


  •  2,214
    WebWizards replied

    Hi John,

    Thank you for purchasing our plugin,


    (1) The $vendor_id variable should be defined previously in your code. So for example:

    $vendor_id = 15;
    echo marketking()->get_store_name_display($vendor_id);

    This will give you the store name of the vendor with the user ID of 15.


    (2) Let me give you another example. You mentioned you are working on the product page template. On the single product page frontend, you may use the following:

    global $post;
    $product_id = $post->ID; // this gives us the product ID of the current product
    $vendor_id = marketking()->get_product_vendor($product_id); // this gives us the vendor id of the current product
    $store_name = marketking()->get_store_name_display($vendor_id)
    

    (this is an example of how you can get the current store name on the single product page)


    (3) To get the terms and conditions of a vendor, you can use this code:

    $terms_conditions = get_user_meta($vendor_id,'marketking_policy_message', true);
    

    (again, the vendor id needs to be defined previously).


    I hope that helps but let me know if you have any questions,.

    Kind regards,

    Stefan

  • John replied

    Helpful Thanks. 

  • John replied

    Is there a master list of all the vendor data variables? It would be nice to not have to put in a support ticket for every single step of the development process. Right now I need:

    Vendor logo, profile image, vendor description, city, state, country, store notice.

    Thanks

  •  2,214
    WebWizards replied

    Hi there,

    For the vendor logo, profile image, vendor description, you can use:

    marketking()->get_store_profile_image_link($vendor_id);
    marketking()->get_store_banner_image_link($vendor_id);
    marketking()->display_about_us($vendor_id);
    

    To get the store notice message:

    $notice_enabled = get_user_meta($vendor_id,'marketking_notice_enabled', true);
    if ($notice_enabled === 'yes'){
        $notice_message = get_user_meta($vendor_id,'marketking_notice_message', true);
    } else {
        $notice_message = '';
    }
    

    For the city / state / country:

    get_user_meta($vendor_id, 'billing_address_1', true);
    get_user_meta($vendor_id, 'billing_address_2', true);
    get_user_meta($vendor_id, 'billing_city', true);
    get_user_meta($vendor_id, 'billing_postcode', true);
    get_user_meta($vendor_id, 'billing_state', true);
    get_user_meta($vendor_id, 'billing_country', true);
    

    You can find information here as well https://woocommerce-multivendor.com/docs/developer-documentation-functions-hooks-custom-code-plugin-integrations/

    All of the info is stored as user meta data, so if there's anything you can't find, the quickest way may be to check the wp_usermeta table for the specific vendor,


    Kind regards,

    Stefan