Advanced Product Options

Active options are only visible in the backend, not the frontend

In order to resolve the APO issue, admin should:

  • Resave an affected product (make sure Design ->Display Product Options = NOT EMPTY)

  • Edit the latest APO installer (example:mysql4-upgrade-3.9.99-4.0.0.php) and add the code:

  <?php
  $attribute = $this->getAttribute('catalog_product', 'options_container');
  if (!empty($attribute['attribute_id'])) {
      $this->run("INSERT INTO `{$this->getTable('catalog_product_entity_varchar')}` (`entity_type_id`, `attribute_id`, `entity_id`, `value`) SELECT '{$attribute['entity_type_id']}' AS entity_type_id, '{$attribute['attribute_id']}' AS attribute_id, `entity_id`, 'container1' AS value FROM `{$this->getTable('catalog_product_entity')}` WHERE entity_id IN (SELECT entity_id FROM {$this->getTable('catalog_product_entity')}) ON DUPLICATE KEY UPDATE `value` = 'container1';");
  }
  • Reinstall the extension’s DB tables by removing customoptions_setup record from core_resource table.

Conflict with “Fixed Quantities” extension by Zetaprints

If you use 'Fixed Quantities' extension by Zetaprints, it will conflict with Advanced Product Options. To fix this conflict you should do the following:

  • Create the folder app/code/community/ZetaPrints/Fixedprices/Model/Fixedprices/
  • Create the file 'Abstract.php' inside it.
  • Add the code in this file:
<?php
if ((string)Mage::getConfig()->getModuleConfig('MageWorx_CustomOptions')->active == 'true'){
       class ZetaPrints_Fixedprices_Model_Fixedprices_Abstract
       extends MageWorx_CustomOptions_Model_Catalog_Product_Type_Price {}
   } else {
       class ZetaPrints_Fixedprices_Model_Fixedprices_Abstract
       extends Mage_Catalog_Model_Product_Type_Price {}
   }
  • Modify the file app/code/community/ZetaPrints/Fixedprices/Model/Fixedprices.php and change the inheritance to:
  <?php

  class ZetaPrints_Fixedprices_Model_Fixedprices extends
  ZetaPrints_Fixedprices_Model_Fixedprices_Abstract {

How to arrange options horizontally

In order to place radio buttons horisontally you should add the code to a css file (for example, skin/frontend/default/default/css/styles.css)

.product-options .divclass ul.options-list li {
  float: left;
    padding: 2px 10px;    
}

.product-options .divclass ul.options-list {
    list-style: none;
    height: 17px;
}

where divclass is a class’s name to apply in the frontend (you may use any name). The divclass is to be put into ‘Div CSS Class’ setting under any option.

How to disable a product price update on the front-end when changing a product Qty

By default Magento doesn’t update a product price on the product page on the front-end if you change the product Qty. However, our extension dynamically updates the product price in this case if the product has custom options. This was done to allow your visitors to see a total price right on the product page.

To disable this functionality you should edit the file /app/design/frontend/default/default/template/customoptions/catalog-product-view-options.phtml

and replace the code:

<?php
getProductQty: function() {
    var qty = 1;
    if ($('qty') && !isNaN(parseInt($('qty').getValue()))) {
        var qty = parseInt($('qty').getValue());
        if (qty <= 0) qty = 1;
    }
    return qty;
},
with the following:

<?php
getProductQty: function() {
    return 1;
},

How to display a certain template’s name on frontend

In order to display an option template’s name on the frontend you should locate and edit the file: /app/code/local/MageWorx/CustomOptions/Model/Catalog/Product/Option.php

In function getProductOptionCollection find the line:

<?php
if ($isProductEditPage) $collection->addTemplateTitleToResult();

and replace it with the line:

<?php
$collection->addTemplateTitleToResult();

This is how you can get the name on the frontend:

<?php
$option->getGroupTitle();

How to remove all custom options for all products

Sometimes you need to remove all custom options from all products at once. You can do this by executing the following SQL query in your database:

DELETE FROM catalog_product_option;

How to remove “+” sign from custom options on the frontend

Many of you often ask us if it is possible to remove the ‘plus’ from an option’s name to make it look like: option_name $1.00

This is how you can do this.

Modify the file www/app/code/local/MageWorx/CustomOptions/Helper/Data.php and replace the current function with the following:

<?php
public function getFormatedOptionPrice($product, $priceStr) {
    return str_replace('+', '', $priceStr);
}

How to remove tier prices block under custom options

In order to remove the block with tier prices, you should edit the file: app/design/frontend/{YOUR_THEME}/{YOUR_TEMPLATE}/template/customoptions/catalog-product-view-options.phtml

Look for the piece of code and comment out/remove it:

<?php
getOptionTierPriceHTML: function(el, opConfig) {
                var opPrice = parseFloat(opConfig['price']);
                var tierPrice = 0;
                var tierSaved = 0;
                var tierHTML = '<ul id="option_tier_prices_'+el.value+'" class="tier-prices product-pricing" style="width:250px;">';

                for (var tierQty in opConfig['tier_prices']) {
                    if (!opConfig['tier_prices'].hasOwnProperty(tierQty)) continue;
                    tierPrice = opConfig['tier_prices'][tierQty];
                    tierSaved = parseInt(100 - ((parseFloat(tierPrice) * 100) / opPrice));
                    tierHTML += '<li><?php echo $helper->__js('Buy') ?> '+tierQty+' <?php echo $helper->__js('for') ?> <span class="price"><?php echo $currencySymbol ?>'+tierPrice+'</span> <?php echo $helper->__js('each') ?> <?php echo $helper->__js('and') ?> <strong class="benefit"><?php echo $helper->__js('save') ?> '+tierSaved+'%</strong></li>';
                }
                tierHTML += '</ul>';
                return tierHTML;
            },

The code above shoud be replaced with this:

<?php
getOptionTierPriceHTML: function(el, opConfig) {
    return '';
},

How to solve conflict with MagicToolbox_MagicZoom extension

MagicToolbox_MagicZoom conflicts with Advanced Product Options extension. To solve this conflict, you need to comment the line #113 out in the file app/code/local/MagicToolbox/MagicZoom/etc/config.xml:

<?php
<product_view_options_type_select>MagicToolbox_MagicZoom_Block_Product_View_Options_Type_Select</product_view_options_type_select>

How to update the APO extension from versions older than 4.16.2 to the latest ones

The module code pool is changed from “local” to “community”. Some module file paths are changed according to the “Magento Extension Developer’s Guide”. To install the module the right way, follow the instruction bellow.

  • Backup and remove folder app/code/local/MageWorx/CustomOptions/
  • Follow the installations instructions.
  • If you have any customizations in Extension’s core move them manually from app/code/local/MageWorx/CustomOptions/ to app/code/community/MageWorx/CustomOptions/
  • Should you have any theme file customizations, check the list of the changed files below and move your custom code from the OLD to the NEW file location (OLD –> NEW):
- app/design/frontend/[YOUR_PACKAGE]/[YOUR_THEME]/template/customoptions/ -> app/design/frontend/[YOUR_PACKAGE]/[YOUR_THEME]/template/mageworx/customoptions/
- app/design/frontend/[YOUR_PACKAGE]/[YOUR_THEME]/layout/customoptions.xml -> app/design/frontend/[YOUR_PACKAGE]/[YOUR_THEME]/layout/mageworx_customoptions.xml
- app/design/adminhtml/default/default/template/customoptions/ -> app/design/adminhtml/default/default/template/mageworx/customoptions/
- app/design/adminhtml/default/default/layout/customoptions.xml -> app/design/adminhtml/default/default/layout/mageworx_customoptions.x

Include images in option’s description

This is what you need to insert into the description field to enable customers to see a linked image:

<a title="" rel="mageworxLightbox[]" href="http://YOUR_WEBSITE/media/customoptions/options/2149/4954/d4d60afe5763d5b43a.jpg">Custom_text</a>

Max input vars is reached

The problem might appear if not all options were sent to PHP in POST. This has nothing to do with the extension, you should just tweak your server’s settings a bit.

Please check your PHP settings using a phpinfo command:

; The value must be equal or higher
max_input_vars = 10000
upload_max_filesize = 12M
post_max_size = 12M
If a Suhosin PHP extension is installed, you should also check these:

<?php
; The value must be equal or higher
client_max_body_size = 12M
suhosin.post.max_vars = 10000
suhosin.request.max_vars = 10000

Presumably there is an intermediate proxy server like nginx between PHP and the sent request process. It may have a limitation for data to be sent.

<?php
; The value must be equal or higher
client_max_body_size = 12M
What should you do if some settings don’t meet the requirements?

  • Locate the .htaccess file in your Magento root folder and add the following lines:

php_value max_input_vars = 10000
php_value upload_max_filesize = 12M
php_value post_max_size = 12M
php_value suhosin.post.max_vars = 10000
php_value suhosin.request.max_vars = 10000
Once done and saved, execute a phpinfo command again and see if the changes have been applied.

  • If your Server API = CGI/FastCGI (see phpinfo), you should create the .user.ini file in your Magento root. The file should contain:
max_input_vars = 10000
upload_max_filesize = 12M
post_max_size = 12M
suhosin.post.max_vars = 10000
suhosin.request.max_vars = 10000
  • This solution is more preferable to the previous ones. You should add the lines below in ect/php.ini:
max_input_vars = 10000
upload_max_filesize = 12M
post_max_size = 12M
suhosin.post.max_vars = 10000
suhosin.request.max_vars = 10000

The changes would require you to restart Apache.

Partial support for Organic Internet’s Simple Configurable Products

In order to get the extensions work together one should edit the file: /app/design/frontend/base/default/layout/simpleconfigurableproducts.xml and comment out the block:

<reference name="product.info.options">
    <action method="setTemplate">
        <template>catalog/product/view/scpoptions.phtml</template>
    </action>
</reference>

Recurring Profiles and SKU policy

If a user wants to use Recurring Profile products, and Enable Custom Options Inventory = YES, then the only possible SKU Policy config will be:

Enable Option SKU Policy = YES
Default Option SKU Policy = Replacement
Apply Option SKU Policy To = Cart and Order

If you don’t have those options setup, then when trying to add a Recurring Profile product that contains Custom Option Inventory options, the store will throw this error

Nominal item can be purchased standalone only. To proceed please remove other items from the quote.
Using the above settings lets you add the item to the cart, and removes the inventory of the custom options items upon checkout as desired.

x-Qty feature: disabling read-only mode of the Qty input

When using the x-Qty feature, this automatically makes the Qty input field (the one beside the ‘Add to Cart’ button) read-only.

In order to enable editing of the input field, you should locate the file: app/design/frontend/{YOUR_THEME}/{YOUR_TEMPLATE}/template/customoptions/catalog-product-view-options.phtml and comment out

<?php
hideQty: function() {
    if (!$('qty')) {
       setTimeout('optionSetQtyProduct.hideQty()', 100);
       return;
    }
    //$('qty').previous('label').style.visibility = 'hidden';
    //$('qty').style.visibility = 'hidden';
    $('qty').writeAttribute('readonly', 'readonly');
},