Okay
  Public Ticket #3959119
Question Regarding Required Fields When Adding Products in MarketKing
Closed

Comments

  •  7
    Barni started the conversation

    Hi Webwizard Team,

    I'm currently working with my developer on setting up required fields when vendors add products to our platform. The idea behind this is to ensure consistency across listings – for example, making sure that every product has a profile image and a price.

    We’ve implemented validation checks for this purpose, but we're encountering performance issues at the database and server level when dealing with a large number of users.

    I noticed that MarketKing, by default, already enforces required fields such as the product title – meaning a product can't be published without it.

    I wanted to ask how you approached this on your end: Are you using client-side validation, server-side rules, or some other method to maintain both consistency and performance?

    We’d really appreciate any tips or insights you could share!

    Best regards,

    Attached files:  Bildschirmfoto 2025-04-17 um 14.31.47.png

  •  2,405
    WebWizards replied

    Hi Barni,

    In MarketKing we use both a client-side validation and a server-side check (just making sure the user did not modify something in-browser).

    Here's how you can do something like that:

    1. Client-side validation:
    - You can hide the default "Publish" button and create a duplicate (fake) one
    - When your duplicate button is clicked, first check if all your conditions are met
    - If conditions pass, use jQuery's .click() to trigger the real button, otherwise show your custom error.

     

    2. Server-side validation (as a safety net):
    - You can hook into MarketKing's PHP action: 'marketking_before_save_product'
    - You can return/exit if requirements aren't met (protecting against client-side manipulation)

     

    This should provide good performance as it's all client validation, and then it's just a simple check on the server side when the product is actually saved, to make sure all required fields are set.

     

    Kind regards,
    Stefan

  •  7