There are only 2 files affected. First we need to pass the gravityform Id to the Cart66Product::gravityGetVariationPrices() function. This is called from Cart66ShortcodeManager::gravityFormToCart. In 1.1.3 this function is at line 484 (models/Cart66ShortcodeManager.php) and you need to change line 492 to:
$options = $product->gravityGetVariationPrices($entry, $formId);
The we modify the Cart66Product::gravityGetVariationPrices function (model/Cart66Product.php). In reverse order to preserve the line numbers:
Insert after line 712:
if ($id && $id == $totalField)
$options[] = '+$'.$value;
Insert after line 705
$totalField == false;
if($formId!=0) {
$gForm = new Cart66GravityReader($formId);
if ($gForm) {
$gFields = $gForm->getStandardFields();
foreach ($gFields as $key => $value)
if (strtolower($value) == 'total')
$totalField = $key;
}
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Gravity Form: " . print_r($totalField, true));
}
And finally modify line 704 to become:
public function gravityGetVariationPrices($gfEntry, $formId = 0) {
Basically you avoid using the "+$x.xx" in any form elements as this is what Cart66 uses to indicate a price-affecting field. The above then converts the "total" field into such a price-affecting field and as a result passes the total as computed by Gravity forms as the complete price. Note that the total field must be called "Total"!! If you want it to be called something else, then you need to edit the comparison in the above. Remember also that changing the quantity in the Cart66 "Shopping Cart" multiplies this total.... could be confusing.
Posted 13 years ago on Wednesday June 22, 2011 |
Permalink