How to hide custom option data in the cart in Magento 2 - magento2

I made a custom option programatically in my cart observer. I want that custom option to be hidden in the cart so that the user can't see it.
$additionalOptions[] = [
'label' => 'Product Customize', // hide attributes
'value' => $filename
];
if(count($additionalOptions) > 0){
$item->addOption(array(
'code' => 'additional_options',
'value' => serialize($additionalOptions)
));
}

Related

Magento2 grid checkbox override old selected values

In Magento2, I have created a module for admin panel. There at Grid i select 2 rows and saved. It works fine.
But when i selected new row(It means 2 old and 1 new row) then it saved only new row rather than all 3 rows id.
My PrepareColumns for checkbox is
protected function _prepareColumns()
{
$this->addColumn(
'in_products[]',
[
'type' => 'checkbox',
'html_name' => 'in_products',
'required' => true,
'values' => $this->_getSelectedProducts(),
'align' => 'center',
'checked' => 'checked',
'index' => 'entity_id',
'header_css_class' => 'col-select',
'column_css_class' => 'col-select'
]
);
Please help me where i made mistake.

Magento 2 shipping address custom dropdown field value not posting

We have added custom field under shipping address in checkout page.
It's select field and we are showing custom option from database. It's working fine but when we click next and move to payment option to place an order at that time value not posting. selected dropdown value not showing in console.
If we add text field instead then it shows value posted in console. What could be the issue?
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
['shippingAddress']['children']['shipping-address-fieldset']['children']['custom-field'] = [
'component' => 'Magento_Ui/js/form/element/abstract',
'config' => [
'customScope' => 'shippingAddress.custom_attributes',
'template' => 'ui/form/field',
'elementTmpl' => 'ui/form/element/select',
'id' => 'custom-field',
'options' => $optionarray
],
'dataScope' => 'shippingAddress.custom_attributes.custom_field',
'label' => 'Custom Field',
'provider' => 'checkoutProvider',
'visible' => true,
'validation' => [],
'sortOrder' => 250,
'id' => 'custom-field'
];
return $jsLayout;
Any help would be appreciated.

how to disable breadcrumb for some controllers yii2?

I want disable or change breadcrumb in Yii2 application. How to do that.I
tried to change with
echo Breadcrumbs::widget([
'itemTemplate' => "<li><i>{link}</i></li>\n", // template for all links
'links' => [
[
'label' => 'Post Category',
'url' => ['post-category/view', 'id' => 10],
'template' => "<li><b>{link}</b></li>\n", // template for this link only
],
['label' => 'Sample Post', 'url' => ['post/edit', 'id' => 1]],
'Edit',
],
]);
Well, first of all change it back to default, which is:
<?= Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]) ?>
According to yii2 documentation if you set the value for $links to an empty array, breadcrumbs will not show up.
How do you do it?
Check above code , the $links value in being set by $this->params['breadcrumbs'] variable, which is available in every view file. So in your view file just do this:
// empty if you don't want breadcrumbs
$this->params['breadcrumbs'] = [];
Otherwise set some value and your breadcrumbs will show up.

add catalog product in wishlist programmatically in magento

I have created a product with custom option and I have showed the detail of this product on a custom page. Now I want to add the product in wishlist with filled custom option by user.
If i have to just add the product in wishlist, I can simply use the following code.
<a href="'.Mage::helper("wishlist")->getAddUrl($_product).'" class="link-cart">Add to Wishlist /a>
but i want to insert the product with custom option. For this i have use following code but it gives me error "Cannot specify wishlist"
$wishlist = Mage::getModel('wishlist/wishlist');
$storeId = Mage::app()->getStore()->getId();
$model = Mage::getModel('catalog/product');
$_product = $model->load($data['productId']);
$params = array(
'product' => $data['productId'],
'qty' => 1,
'store_id' => $storeId,
'options' => array(
'optionId' => 'option value',
'optionId2' => 'option value2',
)
);
$request = new Varien_Object();
$request->setData($params);
$result = $wishlist->addNewItem($_product, $request);
You have to change first line
$wishlist=Mage::getModel('wishlist/wishlist')
to
$wishlist = Mage::helper('wishlist')->getWishlist();

How to apply click event for option button using Zend form

I am new to zend, Below is my piece of code,
$TEST = new Zend_Form_Element_Radio('test', array(
'label' => 'Send:*',
'value' => $data,
'multiOptions' => array(0 => 'TEST1', 1 => 'TEST2',2 => 'TEST3 '),
));
$this->addElement($TEST);
Here i Want to apply onclick event for above 3 option button respectively.Is it possible ?.Kindly help me on this
You would probably be best off using jQuery for this? E.g.:
$(function() {
$("#test").click(function(){
// whatever you need to do
});
});