Prestashop Product customizer - php

I have an application which is a T-Shirt customizer which works very good on it's own. But I need to integrate it into prestashop. So after a user uses the application to customize a t-shirt he has to click Add to cart and the product will be added to cart with a custom price and description.
What I need is for this output to be injected into the PrestaShop cart as a custom product with all the custom information and also the generated custom product image to display next to the details in the cart.
So I have the customizer done, I have allready made a custom module and page for Prestashop but I don't know how to integrate it with the cart. My prestashop knowledge is limited.
How can I do this?

When you use this code in CartController.php
$this->context->cart->addTextFieldToProduct($this->id_product, $r["id_customization_field"], Product::CUSTOMIZE_TEXTFIELD, Tools::getValue('product_description'));
then you only save your custom-description in a customization field. But how do you change the price for this customization?
Of course you have to override getPriceStatic method in product.php file to recalculate the custom price. But there is also another problem: what if the customer add same product into the cart but with a different customization and also a different custom price?
Different customization-text is handeled by your used method and is therefor added correctly to the cart, but the different price calculation just overwrites the first custom price because both customizations are associated with the same product.

I did something similar. Here's how I dealt with it.
My module works on its own. I stored customization in the database via object model from the customizer module. Each customization have an ID.
Prestashop offers customization for each products. I hide it from the customer on the prodct page but I use it to store the ID of the customization. That way, you can see in the cart the customization ID for each customized product.
I used _addCustomization method in the Cart object to store the customization ID. Here's a small example:
$context = Context::getContext();
$result = $context->cart->_addCustomization($id_product, $id_product_attribute, 1, 1, $id_customization, 1);
Hope I'm clear enough.
Does this help you out?

Related

How to add “Variation” product meta tab to custom product type

I'm developing a theme with WooCommerce.
Wanted to enable "variation" tab for my custom product type but have no idea how to do it.
Here is the sample screenshot for reference:
I don't know myself, but Variable products are set up differently from Simple products. If you've set up your custom product based on either the Simple product model or the Abstract product model, it probably won't account for the changes needed for variations.
Have a look at the Variable product object and see how it differs from a Simple one.

Add custom product to cart in WooCommerce

I am currently developing an interface that allows you to customize a product. I am implementing on Wordpress, but I need to generate an order after you finish the customization process. So it is necessary that the data is added as a product in the shopping cart WooCommerce. Is that possible? What would be the procedure?
As per your requirements i assume a following scenario
For example you have a site which which sells printed Tshirts.
The flow of this example site is that a user comes selects a tshirt, customizes the tshirt product say by adding Tshirt's color, Image on tshirt and Tshirt's size.
These customization added by the customer at the frontend on product page or cart can be stored in post meta for that order.
So if your case is some what like this then Yes this is possible.
And you can use the following links which will help you to achieve your goal.
How to Add Custom Data to WooCommerce Order
and
Custom WooCommerce Order Meta
Let me know if this solution works for you.

Magento require coupon to purchase product

After searching on Google for quite a while I am going crazy.
My question: Can you configure Magento to require a coupon code to buy specific product?
This is for a promotion my employer is running, basically we want to allow specific customers to buy specific product in our Magento store before any of our other customers. Thank you for your suggestions.
A brief idea I can give here.
Create a backend module, which has own db tables to save linking of products ID to specific coupon, multiple coupon or just a check that coupon is required, depending on your case. From this Module you should be able to define such linking of product to coupon.
Since customer apply a coupon code at cart page, so we will let customer add product into cart. Then edit isDisabled method of Mage_Checkout_Block_Onepage_Link class. where you will check if your quote has any product from the product-coupon linking defined in your module and coupon is not applied yet. Similar thing you can should do for Multishipping method if it is enabled in your Magento. So whenever coupon coupon code will be applied page will refresh and button will get enabled.
Same check you will need to put in indexAction of Mage_Checkout_OnepageController.

Optional product in a Checkout Cart (/checkout/cart/)

I have created a warranty as a product in magento which has 2 custom checkbox options. This product (warranty) does not have any specific page so I would like to display both the custom options of a warranty products as checkbox when selected one of the custom option the product (warranty) also should get added to the cart. I want to display this addon product (warranty) only when the cart amount is larger then $2000. Is there any way to achieve this function without having to create a module. I have attached a screenshot below to illustrate the custom option.
without having to create a module.
No, there is not way to achieve this functionality without programming a custom module.

Hiding a custom option on a product in Magento

I have several hundred products in my Magento store, all of which have a very similar set of custom options. I used one product as a template, and copied its custom options to all of the other products so that all of the products currently have the same set of custom options.
I would like to disable or hide certain custom options for some products in my store without deleting the option completely. Right now, I only have the ability to delete an option for a product entirely. For example, some products cannot currently be ordered in different colors, but they might be later; I'd like to be able to disable the color option rather than delete it and re-add the entire list of colors later.
Does anyone have any similar experience who can provide me with some help with this problem? Thanks, I really appreciate the help!
Using custom options for attributes like "color" is not a correct approach for Magento. Magento has special product type - Configurable product for the catalog structure you're trying to achieve.
Here's benefits you'll get from using configurable product instead of custom options:
Automatic stock management. You won't need to enable-disable your custom options as soon as some physical item is out of stock - Magento will do it for you.
You won't have to copy all custom options to a new product you create. The attribute for the Attribute set this product belongs to will automatically be available for new entries.
You will have ability to filter your products by the color attribute on Category page using Layered Navigation.
Here's the guide how to create configurable product from the official Magento wiki.

Categories