Source of file ShopGoogleAnalyticsOrder.php
Size: 2,083 Bytes - Last Modified: 2021-12-24T06:34:37+00:00
/var/www/docs.ssmods.com/process/src/code/ShopGoogleAnalyticsOrder.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 | <?php /** * Adds a field to the order to mark if a conversion has been recorded. * * @author Mark Guinn <mark@adaircreative.com> * @date 09.10.2014 * @package apluswhs.com */ class ShopGoogleAnalyticsOrder extends DataExtension { private static $db = array( 'AnalyticsSubmitted' => 'Boolean' ); /** * @return bool */ public function IsConversion() { $state = !$this->owner->IsCart(); // different systems may have some statuses that don't count as a conversion (quotation, etc) $this->owner->extend('updateIsConversion', $state); return $state; } /** * This is a very rudimentary method but it should allow * for a variety of site configurations. If it's incorrect, * it's easy enough to override by decorating the Order class. * @return float */ public function GAShippingTotal() { $total = false; $this->owner->extend('overrideGAShippingTotal', $total); if ($total === false) { $total = 0; foreach ($this->owner->Modifiers() as $mod) { if (strpos($mod->ClassName, 'Shipping') !== false) { $total += $mod->Amount(); } } $this->owner->extend('updateGAShippingTotal', $total); } return $total; } /** * This is a very rudimentary method but it should allow * for a variety of site configurations. If it's incorrect, * it's easy enough to override by decorating the Order class. * @return float */ public function GATaxTotal() { $total = false; $this->owner->extend('overrideGATaxTotal', $total); if ($total === false) { $total = 0; foreach ($this->owner->Modifiers() as $mod) { if (strpos($mod->ClassName, 'Tax') !== false) { $total += $mod->Amount(); } } $this->owner->extend('updateGATaxTotal', $total); } return $total; } } |