Ejemplo n.º 1
0
 function GetXML()
 {
     require_once 'xml-processing/xmlbuilder.php';
     $xml_data = new XmlBuilder();
     $xml_data->Push('checkout-shopping-cart', array('xmlns' => $this->schema_url));
     $xml_data->Push('shopping-cart');
     //Add cart expiration if set
     if ($this->cart_expiration != "") {
         $xml_data->Push('cart-expiration');
         $xml_data->Element('good-until-date', $this->cart_expiration);
         $xml_data->Pop('cart-expiration');
     }
     //Add XML data for each of the items
     $xml_data->Push('items');
     foreach ($this->item_arr as $item) {
         $xml_data->Push('item');
         $xml_data->Element('item-name', $item->item_name);
         $xml_data->Element('item-description', $item->item_description);
         $xml_data->Element('unit-price', $item->unit_price, array('currency' => $item->currency));
         $xml_data->Element('quantity', $item->quantity);
         if ($item->merchant_private_data != '') {
             $xml_data->Element('merchant-private-date', $item->merchant_private_data);
         }
         if ($item->tax_table_selector != '') {
             $xml_data->Element('tax-table-selector', $item->tax_table_selector);
         }
         $xml_data->Pop('item');
     }
     $xml_data->Pop('items');
     if ($this->merchant_private_data != '') {
         $xml_data->Element('merchant-private-data', $this->merchant_private_data);
     }
     $xml_data->Pop('shopping-cart');
     $xml_data->Push('checkout-flow-support');
     $xml_data->Push('merchant-checkout-flow-support');
     if ($this->edit_cart_url != '') {
         $xml_data->Element('edit-cart-url', $this->edit_cart_url);
     }
     if ($this->continue_shopping_url != '') {
         $xml_data->Element('continue-shopping-url', $this->continue_shopping_url);
     }
     if (count($this->shipping_arr) > 0) {
         $xml_data->Push('shipping-methods');
     }
     //Add the shipping methods
     foreach ($this->shipping_arr as $ship) {
         //Pickup shipping handled in else part
         if ($ship->type == "flat-rate" || $ship->type == "merchant-calculated") {
             $xml_data->Push($ship->type . '-shipping', array('name' => $ship->name));
             $xml_data->Element('price', $ship->price, array('currency' => $ship->currency));
             //Check if shipping restrictions have been specifd=ied
             if ($ship->allowed_restrictions || $ship->excluded_restrictions) {
                 $xml_data->Push('shipping-restrictions');
                 //Check if allowed restrictions specified
                 if ($ship->allowed_restrictions) {
                     $xml_data->Push('allowed-areas');
                     if ($ship->allowed_country_area != "") {
                         $xml_data->Element('us-country-area', '', array('country-area' => $ship->allowed_country_area));
                     }
                     foreach ($ship->allowed_state_areas_arr as $current) {
                         $xml_data->Push('us-state-area');
                         $xml_data->Element('state', $current);
                         $xml_data->Pop('us-state-area');
                     }
                     foreach ($ship->allowed_zip_patterns_arr as $current) {
                         $xml_data->Push('us-zip-area');
                         $xml_data->Element('zip-pattern', $current);
                         $xml_data->Pop('us-zip-area');
                     }
                     $xml_data->Pop('allowed-areas');
                 }
                 if ($ship->excluded_restrictions) {
                     $xml_data->Push('allowed-areas');
                     $xml_data->Pop('allowed-areas');
                     $xml_data->Push('excluded-areas');
                     if ($ship->excluded_country_area != "") {
                         $xml_data->Element('us-country-area', '', array('country-area' => $ship->excluded_country_area));
                     }
                     foreach ($ship->excluded_state_areas_arr as $current) {
                         $xml_data->Push('us-state-area');
                         $xml_data->Element('state', $current);
                         $xml_data->Pop('us-state-area');
                     }
                     foreach ($ship->excluded_zip_patterns_arr as $current) {
                         $xml_data->Push('us-zip-area');
                         $xml_data->Element('zip-pattern', $current);
                         $xml_data->Pop('us-zip-area');
                     }
                     $xml_data->Pop('excluded-areas');
                 }
                 $xml_data->Pop('shipping-restrictions');
             }
             $xml_data->Pop($ship->type . '-shipping');
         } else {
             if ($ship->type == "pickup") {
                 $xml_data->Push('pickup', array('name' => $ship->name));
                 $xml_data->Element('price', $ship->price, array('currency' => $ship->currency));
                 $xml_data->Pop('pickup');
             }
         }
     }
     if (count($this->shipping_arr) > 0) {
         $xml_data->Pop('shipping-methods');
     }
     if ($this->request_buyer_phone != "") {
         $xml_data->Element('request-buyer-phone-number', $this->request_buyer_phone);
     }
     if ($this->merchant_calculations_url != "") {
         $xml_data->Push('merchant-calculations');
         $xml_data->Element('merchant-calculations-url', $this->merchant_calculations_url);
         if ($this->accept_merchant_coupons != "") {
             $xml_data->Element('accept-merchant-coupons', $this->accept_merchant_coupons);
         }
         if ($this->accept_gift_certificates != "") {
             $xml_data->Element('accept-gift-certificates', $this->accept_gift_certificates);
         }
         $xml_data->Pop('merchant-calculations');
     }
     //Set Default and Alternate tax tables
     if (count($this->alternate_tax_table_arr) != 0 || isset($this->default_tax_table)) {
         if ($this->merchant_calculated != "") {
             $xml_data->Push('tax-tables', array('merchant-calculated' => $this->merchant_calculated));
         } else {
             $xml_data->Push('tax-tables');
         }
         if (isset($this->default_tax_table)) {
             $curr_table = $this->default_tax_table;
             foreach ($curr_table->tax_rules_arr as $curr_rule) {
                 $xml_data->Push('default-tax-table');
                 $xml_data->Push('tax-rules');
                 foreach ($curr_rule->state_areas_arr as $current) {
                     $xml_data->Push('default-tax-rule');
                     $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
                     $xml_data->Element('rate', $curr_rule->tax_rate);
                     $xml_data->Push('tax-area');
                     if ($curr_rule->country_area != "") {
                         $xml_data->Element('us-country-area', '', array('country-area' => $curr_rule->country_area));
                     }
                     $xml_data->Push('us-state-area');
                     $xml_data->Element('state', $current);
                     $xml_data->Pop('us-state-area');
                     $xml_data->Pop('tax-area');
                     $xml_data->Pop('default-tax-rule');
                 }
                 foreach ($curr_rule->zip_patterns_arr as $current) {
                     $xml_data->Push('default-tax-rule');
                     $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
                     $xml_data->Element('rate', $curr_rule->tax_rate);
                     $xml_data->Push('tax-area');
                     if ($curr_rule->country_area != "") {
                         $xml_data->Element('us-country-area', '', array('country-area' => $curr_rule->country_area));
                     }
                     $xml_data->Push('us-zip-area');
                     $xml_data->Element('zip-pattern', $current);
                     $xml_data->Pop('us-zip-area');
                     $xml_data->Pop('tax-area');
                     $xml_data->Pop('default-tax-rule');
                 }
                 $xml_data->Pop('tax-rules');
                 $xml_data->Pop('default-tax-table');
             }
         }
         if (count($this->alternate_tax_table_arr) != 0) {
             $xml_data->Push('alternate-tax-tables');
             foreach ($this->alternate_tax_table_arr as $curr_table) {
                 foreach ($curr_table->tax_rules_arr as $curr_rule) {
                     $xml_data->Push('alternate-tax-table', array('standalone' => $curr_table->standalone, 'name' => $curr_table->name));
                     $xml_data->Push('alternate-tax-rules');
                     foreach ($curr_rule->state_areas_arr as $current) {
                         $xml_data->Push('alternate-tax-rule');
                         $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
                         $xml_data->Element('rate', $curr_rule->tax_rate);
                         $xml_data->Push('tax-area');
                         if ($curr_rule->country_area != "") {
                             $xml_data->Element('us-country-area', '', array('country-area' => $curr_rule->country_area));
                         }
                         $xml_data->Push('us-state-area');
                         $xml_data->Element('state', $current);
                         $xml_data->Pop('us-state-area');
                         $xml_data->Pop('tax-area');
                         $xml_data->Pop('alternate-tax-rule');
                     }
                     foreach ($curr_rule->zip_patterns_arr as $current) {
                         $xml_data->Push('alternate-tax-rule');
                         $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
                         $xml_data->Element('rate', $curr_rule->tax_rate);
                         $xml_data->Push('tax-area');
                         if ($curr_rule->country_area != "") {
                             $xml_data->Element('us-country-area', '', array('country-area' => $curr_rule->country_area));
                         }
                         $xml_data->Push('us-zip-area');
                         $xml_data->Element('zip-pattern', $current);
                         $xml_data->Pop('us-zip-area');
                         $xml_data->Pop('tax-area');
                         $xml_data->Pop('alternate-tax-rule');
                     }
                     $xml_data->Pop('alternate-tax-rules');
                     $xml_data->Pop('alternate-tax-table');
                 }
             }
             $xml_data->Pop('alternate-tax-tables');
         }
         $xml_data->Pop('tax-tables');
     }
     $xml_data->Pop('merchant-checkout-flow-support');
     $xml_data->Pop('checkout-flow-support');
     $xml_data->Pop('checkout-shopping-cart');
     return $xml_data->GetXML();
 }
 /**
  * @return string
  */
 function GetXML()
 {
     require_once 'xml-processing/xmlbuilder.php';
     $xml_data = new XmlBuilder();
     $xml_data->Push('merchant-calculation-results', array('xmlns' => $this->schema_url));
     $xml_data->Push('results');
     foreach ($this->results_arr as $result) {
         if ($result->shipping_name != "") {
             $xml_data->Push('result', array('shipping-name' => $result->shipping_name, 'address-id' => $result->address_id));
             $xml_data->Element('shipping-rate', $result->ship_price, array('currency' => $result->ship_currency));
             $xml_data->Element('shippable', $result->shippable);
         } else {
             $xml_data->Push('result', array('address-id' => $result->address_id));
         }
         if ($result->tax_amount != "") {
             $xml_data->Element('total-tax', $result->tax_amount, array('currency' => $result->tax_currency));
         }
         if (count($result->coupon_arr) != 0 || count($result->giftcert_arr) != 0) {
             $xml_data->Push('merchant-code-results');
             foreach ($result->coupon_arr as $curr_coupon) {
                 $xml_data->Push('coupon-result');
                 $xml_data->Element('valid', $curr_coupon->coupon_valid);
                 $xml_data->Element('code', $curr_coupon->coupon_code);
                 $xml_data->Element('calculated-amount', $curr_coupon->coupon_amount, array('currency' => $curr_coupon->coupon_currency));
                 $xml_data->Element('message', $curr_coupon->coupon_message);
                 $xml_data->Pop('coupon-result');
             }
             foreach ($result->giftcert_arr as $curr_gift) {
                 $xml_data->Push('gift-result');
                 $xml_data->Element('valid', $curr_gift->gift_valid);
                 $xml_data->Element('code', $curr_gift->gift_code);
                 $xml_data->Element('calculated-amount', $curr_gift->gift_amount, array('currency' => $curr_gift->gift_currency));
                 $xml_data->Element('message', $curr_gift->gift_message);
                 $xml_data->Pop('gift-result');
             }
             $xml_data->Pop('merchant-code-results');
         }
         $xml_data->Pop('result');
     }
     $xml_data->Pop('results');
     $xml_data->Pop('merchant-calculation-results');
     return $xml_data->GetXML();
 }
 /**
  * @param XmlBuilder $xml
  */
 function addToXml(&$xml)
 {
     // TODO: htmlspecialchars should go here?
     $name = empty($this->_rootNamespace) ? $this->_name : $this->_rootNamespace . ':' . $this->_name;
     $value = htmlspecialchars($this->_value);
     if ($this->_children == null) {
         if ($value != '') {
             $xml->Element($name, $value, $this->_attributes);
         } else {
             $xml->EmptyElement($name, $this->_attributes);
         }
     } else {
         $xml->Push($name, $this->_attributes);
         if ($value != '') {
             $xml->Append($value);
         }
         foreach ($this->_children as $child) {
             $child->addToXml($xml);
         }
         $xml->Pop($name);
     }
 }
Ejemplo n.º 4
0
while ($db->nextRecord()) {
    $fieldValue = $db->f('points_widgets');
    $resWidgets[$db->f('ord_date')]['points_widgets'] = isset($resWidgets[$db->f('ord_date')]['points_widgets']) ? $resWidgets[$db->f('ord_date')]['points_widgets'] + $fieldValue : $fieldValue;
    $resWidgets[$db->f('ord_date')]['total_widgets'] = isset($resWidgets[$db->f('ord_date')]['total_widgets']) ? $resWidgets[$db->f('ord_date')]['total_widgets'] + $fieldValue : $fieldValue;
}
#vip
$query = "SELECT COUNT(`id`) AS `vip_widgets`, DATE_FORMAT(`date_premium`, '{$dateFormatSQL}') as `ord_date` FROM `quizzes`\n\t\tWHERE  DATE_FORMAT(`date_premium`, '%Y-%m-%d') >= '{$_POST['date_from']}' \n\t\tAND DATE_FORMAT(`date_premium`, '%Y-%m-%d') <= '{$_POST['date_to']}' AND  `flags` & " . Quiz::FLAG_PREMIUM . "  AND  `premium_type` = 'subscription'  \n\t\tGROUP BY `ord_date` ";
$db = new DbMySql($query);
while ($db->nextRecord()) {
    $fieldValue = $db->f('vip_widgets');
    $resWidgets[$db->f('ord_date')]['vip_widgets'] = isset($resWidgets[$db->f('ord_date')]['vip_widgets']) ? $resWidgets[$db->f('ord_date')]['vip_widgets'] + $fieldValue : $fieldValue;
    $resWidgets[$db->f('ord_date')]['total_widgets'] = isset($resWidgets[$db->f('ord_date')]['total_widgets']) ? $resWidgets[$db->f('ord_date')]['total_widgets'] + $fieldValue : $fieldValue;
}
$xml = new XmlBuilder();
$xml->Push('response');
$xml->Element('code', 200);
$xml->Element('status', ServMessages::getMessage(20));
foreach ($resPoints as $date => $result) {
    $xml->Push('results_points');
    $xml->Element('date', $date);
    $xml->Element('used_points', isset($result['used_points']) ? $result['used_points'] : 0);
    $xml->Element('vip_used_points', isset($result['vip_used_points']) ? $result['vip_used_points'] : 0);
    $xml->Element('total_used_points', isset($result['total_used_points']) ? $result['total_used_points'] : 0);
    $xml->Pop('results_points');
}
foreach ($resWidgets as $date => $result) {
    $xml->Push('results_widgets');
    $xml->Element('date', $date);
    $xml->Element('vip_widgets', isset($result['vip_widgets']) ? $result['vip_widgets'] : 0);
    $xml->Element('points_widgets', isset($result['points_widgets']) ? $result['points_widgets'] : 0);
    $xml->Element('free_widgets', isset($result['free_widgets']) ? $result['free_widgets'] : 0);
 function GetXML()
 {
     require_once 'xml-processing/xmlbuilder.php';
     $xml_data = new XmlBuilder();
     $xml_data->Push('checkout-shopping-cart', array('xmlns' => $this->schema_url));
     $xml_data->Push('shopping-cart');
     //Add cart expiration if set
     if ($this->cart_expiration != "") {
         $xml_data->Push('cart-expiration');
         $xml_data->Element('good-until-date', $this->cart_expiration);
         $xml_data->Pop('cart-expiration');
     }
     //Add XML data for each of the items
     $xml_data->Push('items');
     foreach ($this->item_arr as $item) {
         $xml_data->Push('item');
         $xml_data->Element('item-name', $item->item_name);
         $xml_data->Element('item-description', $item->item_description);
         $xml_data->Element('unit-price', $item->unit_price, array('currency' => $this->currency));
         $xml_data->Element('quantity', $item->quantity);
         if ($item->merchant_private_item_data != '') {
             $xml_data->Element('merchant-private-item-data', $item->merchant_private_item_data);
         }
         if ($item->merchant_item_id != '') {
             $xml_data->Element('merchant-item-id', $item->merchant_item_id);
         }
         if ($item->tax_table_selector != '') {
             $xml_data->Element('tax-table-selector', $item->tax_table_selector);
         }
         $xml_data->Pop('item');
     }
     $xml_data->Pop('items');
     if ($this->merchant_private_data != '') {
         $xml_data->Element('merchant-private-data', $this->merchant_private_data);
     }
     $xml_data->Pop('shopping-cart');
     $xml_data->Push('checkout-flow-support');
     $xml_data->Push('merchant-checkout-flow-support');
     if ($this->edit_cart_url != '') {
         $xml_data->Element('edit-cart-url', $this->edit_cart_url);
     }
     if ($this->continue_shopping_url != '') {
         $xml_data->Element('continue-shopping-url', $this->continue_shopping_url);
     }
     if (count($this->shipping_arr) > 0) {
         $xml_data->Push('shipping-methods');
     }
     //Add the shipping methods
     foreach ($this->shipping_arr as $ship) {
         //Pickup shipping handled in else part
         if ($ship->type == "flat-rate-shipping" || $ship->type == "merchant-calculated-shipping") {
             $xml_data->Push($ship->type, array('name' => $ship->name));
             $xml_data->Element('price', $ship->price, array('currency' => $this->currency));
             $shipping_restrictions = $ship->shipping_restrictions;
             if (isset($shipping_restrictions)) {
                 $xml_data->Push('shipping-restrictions');
                 if ($shipping_restrictions->allow_us_po_box === true) {
                     $xml_data->Element('allow-us-po-box', "true");
                 } else {
                     $xml_data->Element('allow-us-po-box', "false");
                 }
                 //Check if allowed restrictions specified
                 if ($shipping_restrictions->allowed_restrictions) {
                     $xml_data->Push('allowed-areas');
                     if ($shipping_restrictions->allowed_country_area != "") {
                         $xml_data->Element('us-country-area', '', array('country-area' => $shipping_restrictions->allowed_country_area));
                     }
                     foreach ($shipping_restrictions->allowed_state_areas_arr as $current) {
                         $xml_data->Push('us-state-area');
                         $xml_data->Element('state', $current);
                         $xml_data->Pop('us-state-area');
                     }
                     foreach ($shipping_restrictions->allowed_zip_patterns_arr as $current) {
                         $xml_data->Push('us-zip-area');
                         $xml_data->Element('zip-pattern', $current);
                         $xml_data->Pop('us-zip-area');
                     }
                     if ($shipping_restrictions->allowed_world_area === true) {
                         $xml_data->EmptyElement('world-area');
                     }
                     for ($i = 0; $i < count($shipping_restrictions->allowed_country_codes_arr); $i++) {
                         $xml_data->Push('postal-area');
                         $country_code = $shipping_restrictions->allowed_country_codes_arr[$i];
                         $postal_pattern = $shipping_restrictions->allowed_postal_patterns_arr[$i];
                         $xml_data->Element('country-code', $country_code);
                         if ($postal_pattern != "") {
                             $xml_data->Element('postal-code-pattern', $postal_pattern);
                         }
                         $xml_data->Pop('postal-area');
                     }
                     $xml_data->Pop('allowed-areas');
                 }
                 if ($shipping_restrictions->excluded_restrictions) {
                     if (!$shipping_restrictions->allowed_restrictions) {
                         $xml_data->EmptyElement('allowed-areas');
                     }
                     $xml_data->Push('excluded-areas');
                     if ($shipping_restrictions->excluded_country_area != "") {
                         $xml_data->Element('us-country-area', '', array('country-area' => $shipping_restrictions->excluded_country_area));
                     }
                     foreach ($shipping_restrictions->excluded_state_areas_arr as $current) {
                         $xml_data->Push('us-state-area');
                         $xml_data->Element('state', $current);
                         $xml_data->Pop('us-state-area');
                     }
                     foreach ($shipping_restrictions->excluded_zip_patterns_arr as $current) {
                         $xml_data->Push('us-zip-area');
                         $xml_data->Element('zip-pattern', $current);
                         $xml_data->Pop('us-zip-area');
                     }
                     for ($i = 0; $i < count($shipping_restrictions->excluded_country_codes_arr); $i++) {
                         $xml_data->Push('postal-area');
                         $country_code = $shipping_restrictions->excluded_country_codes_arr[$i];
                         $postal_pattern = $shipping_restrictions->excluded_postal_patterns_arr[$i];
                         $xml_data->Element('country-code', $country_code);
                         if ($postal_pattern != "") {
                             $xml_data->Element('postal-code-pattern', $postal_pattern);
                         }
                         $xml_data->Pop('postal-area');
                     }
                     $xml_data->Pop('excluded-areas');
                 }
                 $xml_data->Pop('shipping-restrictions');
             }
             if ($ship->type == "merchant-calculated-shipping") {
                 $address_filters = $ship->address_filters;
                 if (isset($address_filters)) {
                     $xml_data->Push('address-filters');
                     if ($address_filters->allow_us_po_box === true) {
                         $xml_data->Element('allow-us-po-box', "true");
                     } else {
                         $xml_data->Element('allow-us-po-box', "false");
                     }
                     //Check if allowed restrictions specified
                     if ($address_filters->allowed_restrictions) {
                         $xml_data->Push('allowed-areas');
                         if ($address_filters->allowed_country_area != "") {
                             $xml_data->Element('us-country-area', '', array('country-area' => $address_filters->allowed_country_area));
                         }
                         foreach ($address_filters->allowed_state_areas_arr as $current) {
                             $xml_data->Push('us-state-area');
                             $xml_data->Element('state', $current);
                             $xml_data->Pop('us-state-area');
                         }
                         foreach ($address_filters->allowed_zip_patterns_arr as $current) {
                             $xml_data->Push('us-zip-area');
                             $xml_data->Element('zip-pattern', $current);
                             $xml_data->Pop('us-zip-area');
                         }
                         if ($address_filters->allowed_world_area === true) {
                             $xml_data->EmptyElement('world-area');
                         }
                         for ($i = 0; $i < count($address_filters->allowed_country_codes_arr); $i++) {
                             $xml_data->Push('postal-area');
                             $country_code = $address_filters->allowed_country_codes_arr[$i];
                             $postal_pattern = $address_filters->allowed_postal_patterns_arr[$i];
                             $xml_data->Element('country-code', $country_code);
                             if ($postal_pattern != "") {
                                 $xml_data->Element('postal-code-pattern', $postal_pattern);
                             }
                             $xml_data->Pop('postal-area');
                         }
                         $xml_data->Pop('allowed-areas');
                     }
                     if ($address_filters->excluded_restrictions) {
                         if (!$address_filters->allowed_restrictions) {
                             $xml_data->EmptyElement('allowed-areas');
                         }
                         $xml_data->Push('excluded-areas');
                         if ($address_filters->excluded_country_area != "") {
                             $xml_data->Element('us-country-area', '', array('country-area' => $address_filters->excluded_country_area));
                         }
                         foreach ($address_filters->excluded_state_areas_arr as $current) {
                             $xml_data->Push('us-state-area');
                             $xml_data->Element('state', $current);
                             $xml_data->Pop('us-state-area');
                         }
                         foreach ($address_filters->excluded_zip_patterns_arr as $current) {
                             $xml_data->Push('us-zip-area');
                             $xml_data->Element('zip-pattern', $current);
                             $xml_data->Pop('us-zip-area');
                         }
                         for ($i = 0; $i < count($address_filters->excluded_country_codes_arr); $i++) {
                             $xml_data->Push('postal-area');
                             $country_code = $address_filters->excluded_country_codes_arr[$i];
                             $postal_pattern = $address_filters->excluded_postal_patterns_arr[$i];
                             $xml_data->Element('country-code', $country_code);
                             if ($postal_pattern != "") {
                                 $xml_data->Element('postal-code-pattern', $postal_pattern);
                             }
                             $xml_data->Pop('postal-area');
                         }
                         $xml_data->Pop('excluded-areas');
                     }
                     $xml_data->Pop('address-filters');
                 }
             }
             $xml_data->Pop($ship->type);
         } else {
             if ($ship->type == "pickup") {
                 $xml_data->Push('pickup', array('name' => $ship->name));
                 $xml_data->Element('price', $ship->price, array('currency' => $this->currency));
                 $xml_data->Pop('pickup');
             }
         }
     }
     if (count($this->shipping_arr) > 0) {
         $xml_data->Pop('shipping-methods');
     }
     if ($this->request_buyer_phone != "") {
         $xml_data->Element('request-buyer-phone-number', $this->request_buyer_phone);
     }
     if ($this->merchant_calculations_url != "") {
         $xml_data->Push('merchant-calculations');
         $xml_data->Element('merchant-calculations-url', $this->merchant_calculations_url);
         if ($this->accept_merchant_coupons != "") {
             $xml_data->Element('accept-merchant-coupons', $this->accept_merchant_coupons);
         }
         if ($this->accept_gift_certificates != "") {
             $xml_data->Element('accept-gift-certificates', $this->accept_gift_certificates);
         }
         $xml_data->Pop('merchant-calculations');
     }
     //Set Default and Alternate tax tables
     if (count($this->alternate_tax_tables_arr) != 0 || count($this->default_tax_rules_arr) != 0) {
         if ($this->merchant_calculated != "") {
             $xml_data->Push('tax-tables', array('merchant-calculated' => $this->merchant_calculated));
         } else {
             $xml_data->Push('tax-tables');
         }
         if (count($this->default_tax_rules_arr) != 0) {
             $xml_data->Push('default-tax-table');
             $xml_data->Push('tax-rules');
             foreach ($this->default_tax_rules_arr as $curr_rule) {
                 if ($curr_rule->country_area != "") {
                     $xml_data->Push('default-tax-rule');
                     $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
                     $xml_data->Element('rate', $curr_rule->tax_rate);
                     $xml_data->Push('tax-area');
                     $xml_data->Element('us-country-area', '', array('country-area' => $curr_rule->country_area));
                     $xml_data->Pop('tax-area');
                     $xml_data->Pop('default-tax-rule');
                 }
                 foreach ($curr_rule->state_areas_arr as $current) {
                     $xml_data->Push('default-tax-rule');
                     $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
                     $xml_data->Element('rate', $curr_rule->tax_rate);
                     $xml_data->Push('tax-area');
                     $xml_data->Push('us-state-area');
                     $xml_data->Element('state', $current);
                     $xml_data->Pop('us-state-area');
                     $xml_data->Pop('tax-area');
                     $xml_data->Pop('default-tax-rule');
                 }
                 foreach ($curr_rule->zip_patterns_arr as $current) {
                     $xml_data->Push('default-tax-rule');
                     $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
                     $xml_data->Element('rate', $curr_rule->tax_rate);
                     $xml_data->Push('tax-area');
                     $xml_data->Push('us-zip-area');
                     $xml_data->Element('zip-pattern', $current);
                     $xml_data->Pop('us-zip-area');
                     $xml_data->Pop('tax-area');
                     $xml_data->Pop('default-tax-rule');
                 }
                 for ($i = 0; $i < count($curr_rule->country_codes_arr); $i++) {
                     $xml_data->Push('default-tax-rule');
                     $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
                     $xml_data->Element('rate', $curr_rule->tax_rate);
                     $xml_data->Push('tax-area');
                     $xml_data->Push('postal-area');
                     $country_code = $curr_rule->country_codes_arr[$i];
                     $postal_pattern = $curr_rule->postal_patterns_arr[$i];
                     $xml_data->Element('country-code', $country_code);
                     if ($postal_pattern != "") {
                         $xml_data->Element('postal-code-pattern', $postal_pattern);
                     }
                     $xml_data->Pop('postal-area');
                     $xml_data->Pop('tax-area');
                     $xml_data->Pop('default-tax-rule');
                 }
                 if ($curr_rule->world_area === true) {
                     $xml_data->Push('default-tax-rule');
                     $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
                     $xml_data->Element('rate', $curr_rule->tax_rate);
                     $xml_data->Push('tax-area');
                     $xml_data->EmptyElement('world-area');
                     $xml_data->Pop('tax-area');
                     $xml_data->Pop('default-tax-rule');
                 }
             }
             $xml_data->Pop('tax-rules');
             $xml_data->Pop('default-tax-table');
         }
         if (count($this->alternate_tax_tables_arr) != 0) {
             $xml_data->Push('alternate-tax-tables');
             foreach ($this->alternate_tax_tables_arr as $curr_table) {
                 $xml_data->Push('alternate-tax-table', array('standalone' => $curr_table->standalone, 'name' => $curr_table->name));
                 $xml_data->Push('alternate-tax-rules');
                 foreach ($curr_table->tax_rules_arr as $curr_rule) {
                     if ($curr_rule->country_area != "") {
                         $xml_data->Push('alternate-tax-rule');
                         $xml_data->Element('rate', $curr_rule->tax_rate);
                         $xml_data->Push('tax-area');
                         $xml_data->Element('us-country-area', '', array('country-area' => $curr_rule->country_area));
                         $xml_data->Pop('tax-area');
                         $xml_data->Pop('alternate-tax-rule');
                     }
                     foreach ($curr_rule->state_areas_arr as $current) {
                         $xml_data->Push('alternate-tax-rule');
                         $xml_data->Element('rate', $curr_rule->tax_rate);
                         $xml_data->Push('tax-area');
                         $xml_data->Push('us-state-area');
                         $xml_data->Element('state', $current);
                         $xml_data->Pop('us-state-area');
                         $xml_data->Pop('tax-area');
                         $xml_data->Pop('alternate-tax-rule');
                     }
                     foreach ($curr_rule->zip_patterns_arr as $current) {
                         $xml_data->Push('alternate-tax-rule');
                         $xml_data->Element('rate', $curr_rule->tax_rate);
                         $xml_data->Push('tax-area');
                         $xml_data->Push('us-zip-area');
                         $xml_data->Element('zip-pattern', $current);
                         $xml_data->Pop('us-zip-area');
                         $xml_data->Pop('tax-area');
                         $xml_data->Pop('alternate-tax-rule');
                     }
                     for ($i = 0; $i < count($curr_rule->country_codes_arr); $i++) {
                         $xml_data->Push('alternate-tax-rule');
                         $xml_data->Element('rate', $curr_rule->tax_rate);
                         $xml_data->Push('tax-area');
                         $xml_data->Push('postal-area');
                         $country_code = $curr_rule->country_codes_arr[$i];
                         $postal_pattern = $curr_rule->postal_patterns_arr[$i];
                         $xml_data->Element('country-code', $country_code);
                         if ($postal_pattern != "") {
                             $xml_data->Element('postal-code-pattern', $postal_pattern);
                         }
                         $xml_data->Pop('postal-area');
                         $xml_data->Pop('tax-area');
                         $xml_data->Pop('alternate-tax-rule');
                     }
                     if ($curr_rule->world_area === true) {
                         $xml_data->Push('alternate-tax-rule');
                         $xml_data->Element('rate', $curr_rule->tax_rate);
                         $xml_data->Push('tax-area');
                         $xml_data->EmptyElement('world-area');
                         $xml_data->Pop('tax-area');
                         $xml_data->Pop('alternate-tax-rule');
                     }
                 }
                 $xml_data->Pop('alternate-tax-rules');
                 $xml_data->Pop('alternate-tax-table');
             }
             $xml_data->Pop('alternate-tax-tables');
         }
         $xml_data->Pop('tax-tables');
     }
     if ($this->rounding_mode != "" && $this->rounding_rule != "") {
         $xml_data->Push('rounding-policy');
         $xml_data->Element('mode', $this->rounding_mode);
         $xml_data->Element('rule', $this->rounding_rule);
         $xml_data->Pop('rounding-policy');
     }
     $xml_data->Pop('merchant-checkout-flow-support');
     $xml_data->Pop('checkout-flow-support');
     $xml_data->Pop('checkout-shopping-cart');
     return $xml_data->GetXML();
 }
Ejemplo n.º 6
0
<?php

if (empty($_POST['hash'])) {
    $api->outputError(30);
}
$collectionStatus = empty($_POST['collection_status']) ? Quiz::BLOCKED_STATUS_DELETED : $_POST['collection_status'];
$collection = new Quiz();
$collection = $collection->getByHash($_POST['hash']);
$collection->delete();
$blockedCollection = BlockedCollections::getByCollectionId($collection->id);
$blockedCollection->delete();
$xml = new XmlBuilder();
$xml->Push('response');
$xml->Element('code', 200);
$xml->Element('status', ServMessages::getMessage(20));
$xml->Pop('response');
$api->outputXML($xml->GetXML());
Ejemplo n.º 7
0
<?php

if (empty($_POST['hash'])) {
    $api->outputError(30);
}
$collectionStatus = empty($_POST['collection_status']) ? Quiz::BLOCKED_STATUS_TEMP : $_POST['collection_status'];
$hash = $_POST['hash'];
$collection = new Quiz();
$collection = $collection->getByHash($hash);
// Get jobs
if ($collection->id > 0) {
    // Building xml
    $xml = new XmlBuilder();
    $xml->Push('response');
    $xml->Element('code', 200);
    $xml->Element('status', ServMessages::getMessage(20));
    $xml->Push('collection');
    $xml->Element('collection_id', $collection->id);
    $xml->Element('user_id', $collection->user_id);
    $xml->Element('hash', $collection->hash);
    $xml->Pop('collection');
    $xml->Pop('response');
    // Output xml
    $api->outputXML($xml->GetXML());
}
$api->outputError(80);