We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 41428
    • 22 Posts
    Hi All

    I'm looking to make more than just the "reciever" and "email" fields required at the checkout area of miniShop2 v2.1.3-pl2. I tried the easy route of just adding the class "required" to the same container as ".input-parent", but this is stripped automatically upon page load.

    I've found lines 135 + 136 of the [[!msOrder]] snippet:

    $response = $miniShop2->order->getDeliveryRequiresFields();
    $requires = $response['data']['requires'];
    


    Git shows the function getDeliveryRequiresFields() is in the file "core/components/minishop2/model/minishop2/msorderhandler.class.php" lines 275-292:
            /**
             * Returns required fields for delivery
             *
             * @param $id
             *
             * @return array|string
             */
            public function getDeliveryRequiresFields($id = 0) {
                    if (empty($id)) {$id = $this->order['delivery'];}
                    /* @var msDelivery $delivery */
                    if (!$delivery = $this->modx->getObject('msDelivery', array('id' => $id, 'active' => 1))) {
                            return $this->error('ms2_order_err_delivery', array('delivery'));
                    }
                    $requires = $delivery->get('requires');
                    $requires = empty($requires) ? array() : array_map('trim', explode(',', $requires));
                    if (!in_array('email', $requires)) {$requires[] = 'email';}
                    return $this->success('', array('requires' => $requires));
            }
    


    so I tried adjusting my snippet call to:

    [[!msOrder? &requires=`email,receiver,phone,comment,street,city,region,index`]]


    but to no avail, also tried "&delivery=" and "&deliveries="

    Does anyone have any ideas? I'm sure I could hack the core and add my own list into the handler - but that's ugly and no future-proof...

    Thanks in advance

    Kyle [ed. note: kctechsoln last edited this post 10 years, 4 months ago.]
      • 41428
      • 22 Posts
      OK, so I've found that it's looking at the schema "/core/components/minishop2/model/minishop2.mysql.schema.xml", line 164 in the "msDelivery" class, so it means editing the database manually...
        • 41428
        • 22 Posts
        solved...

        No need to hack, it was just a case of finding what to edit...

        Just add the fields to the "requires" fields for each method in "deliverys"