0

how can I attach a custom text to a product which will be added into the cart along with the product itself when adding it to cart and furthermore being passed through the whole order process like in order page in back office or on pdf invoices and so on??

Ex :

  1. When customer is on my product page he has the opportunity to "customize" the product wih the help of a configuration wizard I have built with javascript/jquery.

  2. List item At the end of this process customer can add customized product to cart which now has a custom price and a custom "ordertext" for me as the shop-owner to get all the customization information

  3. When clicking on add-to-cart-button product is added to cart with new customprice and customtext

Please note that my custom text is not entered by customer. Instead it's gonna be generated by programmatically.

enter image description here

0

You can achieve this by creating an event and observer using your extension and setting the custom price and text through observer.

0

We have faced same requirements. So use the below mentioned coding.

1) use observer <catalog_product_collection_load_after> in your config.xml file.

<global>
    <events>
        <catalog_product_collection_load_after>
            <observers>
                <my_code_collection_load_after>
                    <type>singleton</type>
                    <class>My_Code_Model_Observer_Recurring</class>
                    <method>getProductValue</method>
                </my_code_collection_load_after>
            </observers>
        </catalog_product_collection_load_after>
    </events>
</global>

2) Crate custom observer file "root/app/code/community/My/Code/Model/Observer/Recurring.php"

<?php

class My_Code_Model_Observer_Recurring
{

    public function getProductValue(Varien_Event_Observer $observer)
    {
        $quote = Mage::getSingleton('checkout/cart')->getQuote();
        foreach ($quote->getAllItems() as $items) {
            $additionalOptions = $items->getOptionByCode("additional_options");
            if (!empty($additionalOptions)) {
                $additionalValue = unserialize($additionalOptions->getValue());
                if (!isset($additionalValue['nn_subscription']) && empty($additionalValue['nn_subscription'])) {
                    $additionalValue['nn_subscription'] = array('label' => 'Custom Text Title', 'value' => 'Custom Text Value');
                    $serializeData = serialize($additionalValue);
                    $items->getOptionByCode("additional_options")->setValue($serializeData);
                }
            } else {
                $additionalValue['nn_subscription'] = array('label' => 'Custom Text Title', 'value' => 'Custom Text Value');
                $items->addOption(array(
                  "product_id" => $items->getProduct()->getId(),
                  'code' => "additional_options",
                  'value' => serialize($additionalValue)
            ));
            }
        }
    }
}

Checkout cart Page:

enter image description here Checkout review Page:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.