Magento – Order of Values/Labels of Configurable attribute options and custom options on cart page

attributescartconfigurable-productcustom-optionssimple-product

How can I change the order in which Magento lists the Values and Labels of configurable products and the custom options of their associate products.

Example:

Configurable T-shirt has Size and Color attributes, and the simple products ha custom options for Logo placement. When users order a large, red t-shirt with the logo on the front, Magento lists the options in the cart as:

T-Shirt
size-large (attribute)
color-red (attribute)
logo-front (custom option)

I just want the logo-front above size-large, but can't figure out where the list order is created.

(Note: this is a simplistic example. There is a good reason why the "logo position" can't be just another attribute to the config product).

Thanks.

Best Answer

I'm not 100% sure on this, I've ever actually used custom options, but tracing back from the template, I think you'd need to rewrite Mage_Catalog_Helper_Product_Configuration::getCustomOptions. I'm assuming the custom option comes from the additional_options field so at the bottom of that function you can just re-arrange the order:

$addOptions = $item->getOptionByCode('additional_options');
if ($addOptions) {
    // switch around the order of the items in the array like so
    $options = array_merge(unserialize($addOptions->getValue()), $options);
}