Skip to main content

I need to create an observer with creating a block on the cart table, which allowallows the customer to choose from radio button the options I will provide in each item separately in the product table, within the cart page and save it into the database to let the merchant see the options that his clients chose.

 <sales_quote_collect_totals_before>   <observers>   <shippingoptions>   <type>singleton</type>   <class>shippingoptions/observer</class>   <method>test</method>   </shippingoptions>   </observers>  </sales_quote_collect_totals_before> 
  public function test($observer)  {   $quote = $observer->getQuote();   $quote_items = $quote->getItemsCollection();   foreach ($quote_items as $item) { {  $additionalOptions = array(   array(   'title' => 'custom option title',   'type' => 'radio', // could be drop_down ,checkbox , multiple   'is_require' => 1,   'sort_order' => 0,   'values' => $this->getOptions() )   );   $item->addOption(   array(   'code' => 'additional_options',   'value' => serialize($additionalOptions), ) );   } } 

So I figure that I need to use a block to do the rendering thing, I try to dodo that but it didn't go well from my side. So could you help me to do that with from the observer side without overwriting the cart.phtml or any checkout file (And of course for a good reason).?

Here is a screen shotscreenshot just to clarify things up: enter image description here

I need to create an observer with creating a block on the cart table, which allow the customer to choose from radio button the options I will provide in each item separately in the product table, within the cart page and save it into the database to let the merchant see the options that his clients chose.

 <sales_quote_collect_totals_before>   <observers>   <shippingoptions>   <type>singleton</type>   <class>shippingoptions/observer</class>   <method>test</method>   </shippingoptions>   </observers>  </sales_quote_collect_totals_before> 
  public function test($observer)  {   $quote = $observer->getQuote();   $quote_items = $quote->getItemsCollection();   foreach ($quote_items as $item) { $additionalOptions = array(   array(   'title' => 'custom option title',   'type' => 'radio', // could be drop_down ,checkbox , multiple   'is_require' => 1,   'sort_order' => 0,   'values' => $this->getOptions() )   );   $item->addOption(   array(   'code' => 'additional_options',   'value' => serialize($additionalOptions), ) );   } } 

So I figure that I need to use a block to do the rendering thing, I try to do that but it didn't go well from my side. So could you help me to do that with from the observer side without overwriting the cart.phtml or any checkout file (And of course for a good reason).

Here is a screen shot just to clarify things up: enter image description here

I need to create an observer with creating a block on the cart table, which allows the customer to choose from radio button the options I will provide in each item separately in the product table, within the cart page and save it into the database to let the merchant see the options that his clients chose.

<sales_quote_collect_totals_before> <observers> <shippingoptions> <type>singleton</type> <class>shippingoptions/observer</class> <method>test</method> </shippingoptions> </observers> </sales_quote_collect_totals_before> 
 public function test($observer) { $quote = $observer->getQuote(); $quote_items = $quote->getItemsCollection(); foreach ($quote_items as $item) {  $additionalOptions = array( array( 'title' => 'custom option title', 'type' => 'radio', // could be drop_down ,checkbox , multiple 'is_require' => 1, 'sort_order' => 0, 'values' => $this->getOptions() ) ); $item->addOption( array( 'code' => 'additional_options', 'value' => serialize($additionalOptions), ) ); } } 

So I figure that I need to use a block to do the rendering thing, I try to do that but it didn't go well from my side. So could you help me to do that with from the observer side without overwriting the cart.phtml or any checkout file (And of course for a good reason)?

Here is a screenshot just to clarify things up: enter image description here

My config.xmlconfig.xml

 
custom option title
radio
1
0
Array
<dd>custom option title<br> radio<br> 1<br> 0<br> Array </dd>

My config.xml

 
custom option title
radio
1
0
Array

My config.xml

<dd>custom option title<br> radio<br> 1<br> 0<br> Array </dd> 
deleted 15 characters in body
Source Link
Amit Bera
  • 77.8k
  • 21
  • 127
  • 240

Thanks a lot :)

Thanks a lot :)

Source Link
Loading