Magento 1.9 change custom option value depending on stock numberMagento 1.9 if SKU Code Equals… code example not working - help :DMagento 1.8.1.0: Display Quantity In Drop Down list of product options, editing select.phtmlMagento 1.9: Price resetting to 0 when custom option is changedMagento 1.9 - echo Product Stock Alert next to “Out of Stock” LabelChange values of custom option of product in magento 1.9Magento Custom Options with stockMagento 1.9 custom options not adding to cartNumbers at the end of a URL Magento 1.9Magento 1.9 - Use backorder stock instead of actual stock for certain productsHow to create custom options with related dependencies on Magento 1.9?Magento 1.9 Product out of stock shipping time

During copyediting, journal disagrees about spelling of paper's main topic

Bishop game - python

Was the Ford Model T black because of the speed black paint dries?

PIC12F675 GP4 doesn't work

How can one write good dialogue in a story without sounding wooden?

Why does the autopilot disengage even when it does not receive pilot input?

Is an acid a salt or not?

Repeating redundant information after dialogues, to avoid or not?

Who Can Help Retag This?

Cubic programming and beyond?

What would be the ideal melee weapon made of "Phase Metal"?

Where is the USB2 OTG port on the RPi 4 Model B located?

How can I deal with a player trying to insert real-world mythology into my homebrew setting?

Robbers: The Hidden OEIS Substring

Why is dry soil hydrophobic? Bad gardener paradox

Bronze Age Underwater Civilization

What is this welding tool I found in my attic?

Why are they 'nude photos'?

What's the point of this scene involving Flash Thompson at the airport?

Can I intentionally omit previous work experience or pretend it doesn't exist when applying for jobs?

Was I subtly told to resign?

Cops: The Hidden OEIS Substring

Why did the Japanese attack the Aleutians at the same time as Midway?

QGIS Welcome page: What is 'pin to list' for?



Magento 1.9 change custom option value depending on stock number


Magento 1.9 if SKU Code Equals… code example not working - help :DMagento 1.8.1.0: Display Quantity In Drop Down list of product options, editing select.phtmlMagento 1.9: Price resetting to 0 when custom option is changedMagento 1.9 - echo Product Stock Alert next to “Out of Stock” LabelChange values of custom option of product in magento 1.9Magento Custom Options with stockMagento 1.9 custom options not adding to cartNumbers at the end of a URL Magento 1.9Magento 1.9 - Use backorder stock instead of actual stock for certain productsHow to create custom options with related dependencies on Magento 1.9?Magento 1.9 Product out of stock shipping time






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have custom code that determines if a custom code value exists and if it does to select this option over the default sort order option in the product config.



What I am wanting to do is further add logic that if the product sku starts with "F" then it will show the default sort order value for that product.



The custom code is in this file..



appcodelocalMageCatalogBlockProductViewOptionsTypeSelect.php



Here is the code in question



 // Set Default for the following cases:
// Ring Size for Men = T, Women = M
// Price for Custom Option is $0 and is the last, unless defaulted by Men or Women.
// if ($_value->getTitle() == 'M' && $isFemale)
// $select->setValue($_value->getOptionTypeId());
//
// else if ($_value->getTitle() == 'T' && $isMale)
// $select->setValue($_value->getOptionTypeId());
//
// else if ($_value->getPrice() == 0.0000 && $hasNoPrice && !$isFemale && !$isMale)
// $select->setValue($_value->getOptionTypeId());
//

if ($_value->getTitle() == 'M')
$select->setValue($_value->getOptionTypeId());

else if ($_value->getTitle() == 'T')
$select->setValue($_value->getOptionTypeId());

}


This code is ok as is.. but what I am wanting to add to the statements is that if the Stock code starts with 'F' then assign the default value.



something like



if ($sku_code == 'F')
$select->setValue($configValue);



where this will show the default sort order value for the option..



I just cant seem to get this working.



Any help coding this and you get instant kudos and good Karma!



cheers



update Here is full code from Select.php



<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
* @package Mage_Catalog
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/


/**
* Product options text type block
*
* @category Mage
* @package Mage_Catalog
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_Catalog_Block_Product_View_Options_Type_Select
extends Mage_Catalog_Block_Product_View_Options_Abstract

/**
* Return html for control element
*
* @return string
*/
public function getValuesHtml()












share|improve this question
























  • Can you post your full template file where you're trying to do this?

    – giolliano sulit
    Mar 26 at 11:39











  • @giollianosulit have added code from Select.php.. This is where the defaults are being added. Hope this helps.

    – Craig Gillett
    Mar 27 at 0:43


















0















I have custom code that determines if a custom code value exists and if it does to select this option over the default sort order option in the product config.



What I am wanting to do is further add logic that if the product sku starts with "F" then it will show the default sort order value for that product.



The custom code is in this file..



appcodelocalMageCatalogBlockProductViewOptionsTypeSelect.php



Here is the code in question



 // Set Default for the following cases:
// Ring Size for Men = T, Women = M
// Price for Custom Option is $0 and is the last, unless defaulted by Men or Women.
// if ($_value->getTitle() == 'M' && $isFemale)
// $select->setValue($_value->getOptionTypeId());
//
// else if ($_value->getTitle() == 'T' && $isMale)
// $select->setValue($_value->getOptionTypeId());
//
// else if ($_value->getPrice() == 0.0000 && $hasNoPrice && !$isFemale && !$isMale)
// $select->setValue($_value->getOptionTypeId());
//

if ($_value->getTitle() == 'M')
$select->setValue($_value->getOptionTypeId());

else if ($_value->getTitle() == 'T')
$select->setValue($_value->getOptionTypeId());

}


This code is ok as is.. but what I am wanting to add to the statements is that if the Stock code starts with 'F' then assign the default value.



something like



if ($sku_code == 'F')
$select->setValue($configValue);



where this will show the default sort order value for the option..



I just cant seem to get this working.



Any help coding this and you get instant kudos and good Karma!



cheers



update Here is full code from Select.php



<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
* @package Mage_Catalog
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/


/**
* Product options text type block
*
* @category Mage
* @package Mage_Catalog
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_Catalog_Block_Product_View_Options_Type_Select
extends Mage_Catalog_Block_Product_View_Options_Abstract

/**
* Return html for control element
*
* @return string
*/
public function getValuesHtml()












share|improve this question
























  • Can you post your full template file where you're trying to do this?

    – giolliano sulit
    Mar 26 at 11:39











  • @giollianosulit have added code from Select.php.. This is where the defaults are being added. Hope this helps.

    – Craig Gillett
    Mar 27 at 0:43














0












0








0








I have custom code that determines if a custom code value exists and if it does to select this option over the default sort order option in the product config.



What I am wanting to do is further add logic that if the product sku starts with "F" then it will show the default sort order value for that product.



The custom code is in this file..



appcodelocalMageCatalogBlockProductViewOptionsTypeSelect.php



Here is the code in question



 // Set Default for the following cases:
// Ring Size for Men = T, Women = M
// Price for Custom Option is $0 and is the last, unless defaulted by Men or Women.
// if ($_value->getTitle() == 'M' && $isFemale)
// $select->setValue($_value->getOptionTypeId());
//
// else if ($_value->getTitle() == 'T' && $isMale)
// $select->setValue($_value->getOptionTypeId());
//
// else if ($_value->getPrice() == 0.0000 && $hasNoPrice && !$isFemale && !$isMale)
// $select->setValue($_value->getOptionTypeId());
//

if ($_value->getTitle() == 'M')
$select->setValue($_value->getOptionTypeId());

else if ($_value->getTitle() == 'T')
$select->setValue($_value->getOptionTypeId());

}


This code is ok as is.. but what I am wanting to add to the statements is that if the Stock code starts with 'F' then assign the default value.



something like



if ($sku_code == 'F')
$select->setValue($configValue);



where this will show the default sort order value for the option..



I just cant seem to get this working.



Any help coding this and you get instant kudos and good Karma!



cheers



update Here is full code from Select.php



<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
* @package Mage_Catalog
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/


/**
* Product options text type block
*
* @category Mage
* @package Mage_Catalog
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_Catalog_Block_Product_View_Options_Type_Select
extends Mage_Catalog_Block_Product_View_Options_Abstract

/**
* Return html for control element
*
* @return string
*/
public function getValuesHtml()












share|improve this question
















I have custom code that determines if a custom code value exists and if it does to select this option over the default sort order option in the product config.



What I am wanting to do is further add logic that if the product sku starts with "F" then it will show the default sort order value for that product.



The custom code is in this file..



appcodelocalMageCatalogBlockProductViewOptionsTypeSelect.php



Here is the code in question



 // Set Default for the following cases:
// Ring Size for Men = T, Women = M
// Price for Custom Option is $0 and is the last, unless defaulted by Men or Women.
// if ($_value->getTitle() == 'M' && $isFemale)
// $select->setValue($_value->getOptionTypeId());
//
// else if ($_value->getTitle() == 'T' && $isMale)
// $select->setValue($_value->getOptionTypeId());
//
// else if ($_value->getPrice() == 0.0000 && $hasNoPrice && !$isFemale && !$isMale)
// $select->setValue($_value->getOptionTypeId());
//

if ($_value->getTitle() == 'M')
$select->setValue($_value->getOptionTypeId());

else if ($_value->getTitle() == 'T')
$select->setValue($_value->getOptionTypeId());

}


This code is ok as is.. but what I am wanting to add to the statements is that if the Stock code starts with 'F' then assign the default value.



something like



if ($sku_code == 'F')
$select->setValue($configValue);



where this will show the default sort order value for the option..



I just cant seem to get this working.



Any help coding this and you get instant kudos and good Karma!



cheers



update Here is full code from Select.php



<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
* @package Mage_Catalog
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/


/**
* Product options text type block
*
* @category Mage
* @package Mage_Catalog
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_Catalog_Block_Product_View_Options_Type_Select
extends Mage_Catalog_Block_Product_View_Options_Abstract

/**
* Return html for control element
*
* @return string
*/
public function getValuesHtml()









magento product magento-1.9 option






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 0:43







Craig Gillett

















asked Mar 26 at 1:53









Craig GillettCraig Gillett

136 bronze badges




136 bronze badges












  • Can you post your full template file where you're trying to do this?

    – giolliano sulit
    Mar 26 at 11:39











  • @giollianosulit have added code from Select.php.. This is where the defaults are being added. Hope this helps.

    – Craig Gillett
    Mar 27 at 0:43


















  • Can you post your full template file where you're trying to do this?

    – giolliano sulit
    Mar 26 at 11:39











  • @giollianosulit have added code from Select.php.. This is where the defaults are being added. Hope this helps.

    – Craig Gillett
    Mar 27 at 0:43

















Can you post your full template file where you're trying to do this?

– giolliano sulit
Mar 26 at 11:39





Can you post your full template file where you're trying to do this?

– giolliano sulit
Mar 26 at 11:39













@giollianosulit have added code from Select.php.. This is where the defaults are being added. Hope this helps.

– Craig Gillett
Mar 27 at 0:43






@giollianosulit have added code from Select.php.. This is where the defaults are being added. Hope this helps.

– Craig Gillett
Mar 27 at 0:43













1 Answer
1






active

oldest

votes


















0














maybe I don't understand right but you want to see if the sku_code starts with "f"?



EDIT:



if ($sku_code == 'F') 
$select->setValue($configValue);



Try:



if (strpos($sku_code, 'F') === 0) 
$select->setValue($configValue);



Or perhaps:



if (substr($sku_code, 0, 1) === 'F') $select->setValue($configValue); 


Hope it helps :)






share|improve this answer

























  • yes correct.. want to see if starts with f and in that case show default value. Your on the right track here and it does kind of work but it is now applying the default value for all sku codes. not just the ones starting with F..

    – Craig Gillett
    Apr 3 at 11:48










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55348771%2fmagento-1-9-change-custom-option-value-depending-on-stock-number%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














maybe I don't understand right but you want to see if the sku_code starts with "f"?



EDIT:



if ($sku_code == 'F') 
$select->setValue($configValue);



Try:



if (strpos($sku_code, 'F') === 0) 
$select->setValue($configValue);



Or perhaps:



if (substr($sku_code, 0, 1) === 'F') $select->setValue($configValue); 


Hope it helps :)






share|improve this answer

























  • yes correct.. want to see if starts with f and in that case show default value. Your on the right track here and it does kind of work but it is now applying the default value for all sku codes. not just the ones starting with F..

    – Craig Gillett
    Apr 3 at 11:48















0














maybe I don't understand right but you want to see if the sku_code starts with "f"?



EDIT:



if ($sku_code == 'F') 
$select->setValue($configValue);



Try:



if (strpos($sku_code, 'F') === 0) 
$select->setValue($configValue);



Or perhaps:



if (substr($sku_code, 0, 1) === 'F') $select->setValue($configValue); 


Hope it helps :)






share|improve this answer

























  • yes correct.. want to see if starts with f and in that case show default value. Your on the right track here and it does kind of work but it is now applying the default value for all sku codes. not just the ones starting with F..

    – Craig Gillett
    Apr 3 at 11:48













0












0








0







maybe I don't understand right but you want to see if the sku_code starts with "f"?



EDIT:



if ($sku_code == 'F') 
$select->setValue($configValue);



Try:



if (strpos($sku_code, 'F') === 0) 
$select->setValue($configValue);



Or perhaps:



if (substr($sku_code, 0, 1) === 'F') $select->setValue($configValue); 


Hope it helps :)






share|improve this answer















maybe I don't understand right but you want to see if the sku_code starts with "f"?



EDIT:



if ($sku_code == 'F') 
$select->setValue($configValue);



Try:



if (strpos($sku_code, 'F') === 0) 
$select->setValue($configValue);



Or perhaps:



if (substr($sku_code, 0, 1) === 'F') $select->setValue($configValue); 


Hope it helps :)







share|improve this answer














share|improve this answer



share|improve this answer








edited Apr 4 at 9:16

























answered Apr 2 at 12:04









RustyjimRustyjim

5333 silver badges14 bronze badges




5333 silver badges14 bronze badges












  • yes correct.. want to see if starts with f and in that case show default value. Your on the right track here and it does kind of work but it is now applying the default value for all sku codes. not just the ones starting with F..

    – Craig Gillett
    Apr 3 at 11:48

















  • yes correct.. want to see if starts with f and in that case show default value. Your on the right track here and it does kind of work but it is now applying the default value for all sku codes. not just the ones starting with F..

    – Craig Gillett
    Apr 3 at 11:48
















yes correct.. want to see if starts with f and in that case show default value. Your on the right track here and it does kind of work but it is now applying the default value for all sku codes. not just the ones starting with F..

– Craig Gillett
Apr 3 at 11:48





yes correct.. want to see if starts with f and in that case show default value. Your on the right track here and it does kind of work but it is now applying the default value for all sku codes. not just the ones starting with F..

– Craig Gillett
Apr 3 at 11:48








Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55348771%2fmagento-1-9-change-custom-option-value-depending-on-stock-number%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해