Jump to content

how to make customization filed supports other format


Recommended Posts

@sarasallam

That's really weird, whey it says "file fields" but only allows pictures.

I'm afraid that, you have to do quite much customization here.

 

1. Add a new type in BO > product page.

Look at the code in /admin/themes/default/template/controllers/products/customization.tpl

And do the similar thing.

For example, you can add the third type: "My fields".

 

2. Show your custom fields at FE > product page:

Refer to the file /themes/default-bootstrap/product.tpl, then look up section "< ! - - Customization - - >"

 

3. Accept custom fields from your users

Open /controllers/front/ProductController.php, and locate to ProductControllerCore::initContent(), this is the right place for you:

			if (Tools::isSubmit('submitCustomizedDatas'))
			{
				// If cart has not been saved, we need to do it so that customization fields can have an id_cart
				// We check that the cookie exists first to avoid ghost carts
				if (!$this->context->cart->id && isset($_COOKIE[$this->context->cookie->getName()]))
				{
					$this->context->cart->add();
					$this->context->cookie->id_cart = (int)$this->context->cart->id;
				}
				$this->pictureUpload();
				$this->uploadMyFields();// Here you go, of course, create your own function "uploadMyFields" to handle uploading. It should be similiar to $this->pictureUpload();
				$this->textRecord();
				$this->formTargetFormat();
			}

4. If you don't know how to process uploading a file (rather than images), back to BO > Product page > Attachment and study how Prestashop does the same thing.

 

Hope this helps!

Link to comment
Share on other sites

×
×
  • Create New...