News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Google Certified Shop Integration

Started by merseyman, October 22, 2015, 15:30:09 PM

Previous topic - Next topic

merseyman

I was wondering if anyone been through the Google Certified Shop integration process, as there are a few fields in the Google Certified Shops Order script which I need a little help with.
Here's the variables that need mapping to VM3 database fields ...

<!-- start order and merchant information -->
  <span id="gts-o-email">CUSTOMER_EMAIL</span>
  <span id="gts-o-country">CUSTOMER_COUNTRY</span>
  <span id="gts-o-total">ORDER_TOTAL</span>
  <span id="gts-o-discounts">ORDER_DISCOUNTS</span>
  <span id="gts-o-shipping-total">ORDER_SHIPPING</span>
  <span id="gts-o-tax-total">ORDER_TAX</span>
  <span id="gts-o-est-ship-date">ORDER_EST_SHIP_DATE</span> (Required Format: YYYY-MM-DD)
  <span id="gts-o-est-delivery-date">ORDER_EST_DELIVERY_DATE</span> (Required Format: YYYY-MM-DD)
  <!-- end order and merchant information -->

  <!-- start repeated item specific information -->
  <!-- item example: this area repeated for each item in the order -->
  <span class="gts-item">
    <span class="gts-i-name">ITEM_NAME</span>
    <span class="gts-i-price">ITEM_PRICE</span>
    <span class="gts-i-quantity">ITEM_QUANTITY</span>
     </span>
  <!-- end item 1 example -->
  <!-- end repeated item specific information -->

If anyone's able to help, I'll find a way of buying you a beer, or two ;-)

Thanks,
Rob

Typhoon365

Here is a sample of what we are using, we added it in : /plugins/vmpayment/paypal/paypal/tmpl/stdresponse.php.

Please note, we only implemented recently and are in the evaluation period with Google Trusted Store.  Please review the code and make your own adjustments, should be something to get you started with at least.

We've only implemented it for PayPal completed payments, if you accept payments by other mechanisms you will need to add something similar to other payment plug-ins.

Notes :
- Replace with your domain name
- For estimated delivery dates, please adjust to your own requirements.
- Replace store id with your own if you have a product feed to Google Merchant Centre.
- Replace AUD currency with whatever currency you us.  We hardcoded, you could probably get it from the order or system.
- Discounts, you might need to adjust code still.  Have tested if it includes coupon discounts or not, might need some adjusting still.


# $date must be in YYYY-MM-DD format
# You can pass in either an array of holidays in YYYYMMDD format
# OR a URL for a .ics file containing holidays
# this defaults to the UK government holiday data for England and Wales
function addBusinessDays($date,$numDays=1,$holidays='') {
#   if ($holidays==='') $holidays = 'https://www.gov.uk/bank-holidays/england-and-wales.ics';

    if (!is_array($holidays)) {
        $ch = curl_init($holidays);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
        $ics = curl_exec($ch);
        curl_close($ch);
        $ics = explode("\n",$ics);
        $ics = preg_grep('/^DTSTART;/',$ics);
        $holidays = preg_replace('/^DTSTART;VALUE=DATE:(\\d{4})(\\d{2})(\\d{2}).*/s','$1-$2-$3',$ics);
    }

    $addDay = 0;
    while ($numDays--) {
        while (true) {
            $addDay++;
            $newDate = date('Y-m-d', strtotime("$date +$addDay Days"));
            $newDayOfWeek = date('w', strtotime($newDate));
            if ( $newDayOfWeek>0 && $newDayOfWeek<6 && !in_array($newDate,$holidays)) break;
        }
    }

    return $newDate;
}
?>
<div id="gts-order" style="display:none;" translate="no">
<span><?php echo print_r($order['items'], true); ?></span>
<span id="gts-o-id"><?php echo $order['details']['BT']->order_number ?></span>
<span id="gts-o-domain">www.yourdomain.com.au</span>
<span id="gts-o-email"><?php echo $order['details']['BT']->email ?></span>
<span id="gts-o-country"><?php echo ShopFunctions::getCountryByID($order['details']['BT']->virtuemart_country_id'country_2_code'); ?></span>
<span id="gts-o-currency">AUD</span>
<span id="gts-o-total"><?php echo round($order['details']['BT']->order_total,2?></span>
<span id="gts-o-discounts">-<?php echo round($order['details']['BT']->order_discount,2?></span>
<span id="gts-o-shipping-total"><?php echo round($order['details']['BT']->order_shipment,2?></span>
<span id="gts-o-tax-total"><?php echo round($order['details']['BT']->order_total/1.1*0.1,2?></span>
<span id="gts-o-est-ship-date"><?php echo addBusinessDays(date("Y-m-d"),2?></span>
<span id="gts-o-est-delivery-date"><?php echo addBusinessDays(date("Y-m-d"),10?></span>
<span id="gts-o-has-preorder">N</span>
<span id="gts-o-has-digital">N</span>

<?php foreach ($order['items'] as $i => $item) : ?>
<span class="gts-item">
<span class="gts-i-name"><?php echo $item->order_item_name ?></span>
<span class="gts-i-price"><?php echo round($item->product_final_price,2?></span>
<span class="gts-i-quantity"><?php echo $item->product_quantity ?></span>
<span class="gts-i-prodsearch-id"><?php echo $item->order_item_sku ?></span>
<span class="gts-i-prodsearch-store-id">xxxxxx</span>
</span>
<?php endforeach; ?>

</div>

avisbag

#2
VM 2.6.22 I'm trying to do something similar with Shopper Approved, except it uses javascript. So I assume I'll have to use a foreach loop for mine as well? Not sure how to format this, but I am pretty sure I know/can get the proper variables at least. Any help would be awesome. I'm so overwhelmed.

<script type="text/javascript">
/* Include all products in the object below 'product id':'Product Name' */
var sa_products = { 'productid1':'Product Description One', 'productid2':'Product Description Two', 'productid3':'Product Description Three' };
</script>


<script type="text/javascript"> var sa_values = { 'site':20541, 'name':'John Doe', 'email':'', 'forcecomments':1, 'emailAll':1 }; function saLoadScript(src) { var js = window.document.createElement("script"); js.src = src; js.type = "text/javascript"; document.getElementsByTagName("head")[0].appendChild(js); } var d = new Date(); if (d.getTime() - 172800000 > 1452717358000) saLoadScript("//www.shopperapproved.com/thankyou/rate/20541.js"); else saLoadScript("//direct.shopperapproved.com/thankyou/rate/20541.js?d=" + d.getTime()); </script>

sandstorm

"Typhoon365" How did this work out for you?
Looking to do the same for a Joomla 3.5 VM3.0.14 site myself
J3.6.4 / PHP7.0.12
VM3.0.16

Typhoon365

The code worked well.   

Please note for Google Trusted Store they currently exclude transactions from mobile devices, so when calculating if you have sufficient volume to meeting their min. monthly transaction volumes just take this into consideration.

protecautocare

Quote from: Typhoon365 on October 25, 2015, 08:03:56 AM
Here is a sample of what we are using, we added it in : /plugins/vmpayment/paypal/paypal/tmpl/stdresponse.php.

Please note, we only implemented recently and are in the evaluation period with Google Trusted Store.  Please review the code and make your own adjustments, should be something to get you started with at least.

We've only implemented it for PayPal completed payments, if you accept payments by other mechanisms you will need to add something similar to other payment plug-ins.

Notes :
- Replace with your domain name
- For estimated delivery dates, please adjust to your own requirements.
- Replace store id with your own if you have a product feed to Google Merchant Centre.
- Replace AUD currency with whatever currency you us.  We hardcoded, you could probably get it from the order or system.
- Discounts, you might need to adjust code still.  Have tested if it includes coupon discounts or not, might need some adjusting still.


# $date must be in YYYY-MM-DD format
# You can pass in either an array of holidays in YYYYMMDD format
# OR a URL for a .ics file containing holidays
# this defaults to the UK government holiday data for England and Wales
function addBusinessDays($date,$numDays=1,$holidays='') {
#   if ($holidays==='') $holidays = 'https://www.gov.uk/bank-holidays/england-and-wales.ics';

    if (!is_array($holidays)) {
        $ch = curl_init($holidays);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
        $ics = curl_exec($ch);
        curl_close($ch);
        $ics = explode("\n",$ics);
        $ics = preg_grep('/^DTSTART;/',$ics);
        $holidays = preg_replace('/^DTSTART;VALUE=DATE:(\\d{4})(\\d{2})(\\d{2}).*/s','$1-$2-$3',$ics);
    }

    $addDay = 0;
    while ($numDays--) {
        while (true) {
            $addDay++;
            $newDate = date('Y-m-d', strtotime("$date +$addDay Days"));
            $newDayOfWeek = date('w', strtotime($newDate));
            if ( $newDayOfWeek>0 && $newDayOfWeek<6 && !in_array($newDate,$holidays)) break;
        }
    }

    return $newDate;
}
?>
<div id="gts-order" style="display:none;" translate="no">
<span><?php echo print_r($order['items'], true); ?></span>
<span id="gts-o-id"><?php echo $order['details']['BT']->order_number ?></span>
<span id="gts-o-domain">www.yourdomain.com.au</span>
<span id="gts-o-email"><?php echo $order['details']['BT']->email ?></span>
<span id="gts-o-country"><?php echo ShopFunctions::getCountryByID($order['details']['BT']->virtuemart_country_id'country_2_code'); ?></span>
<span id="gts-o-currency">AUD</span>
<span id="gts-o-total"><?php echo round($order['details']['BT']->order_total,2?></span>
<span id="gts-o-discounts">-<?php echo round($order['details']['BT']->order_discount,2?></span>
<span id="gts-o-shipping-total"><?php echo round($order['details']['BT']->order_shipment,2?></span>
<span id="gts-o-tax-total"><?php echo round($order['details']['BT']->order_total/1.1*0.1,2?></span>
<span id="gts-o-est-ship-date"><?php echo addBusinessDays(date("Y-m-d"),2?></span>
<span id="gts-o-est-delivery-date"><?php echo addBusinessDays(date("Y-m-d"),10?></span>
<span id="gts-o-has-preorder">N</span>
<span id="gts-o-has-digital">N</span>

<?php foreach ($order['items'] as $i => $item) : ?>
<span class="gts-item">
<span class="gts-i-name"><?php echo $item->order_item_name ?></span>
<span class="gts-i-price"><?php echo round($item->product_final_price,2?></span>
<span class="gts-i-quantity"><?php echo $item->product_quantity ?></span>
<span class="gts-i-prodsearch-id"><?php echo $item->order_item_sku ?></span>
<span class="gts-i-prodsearch-store-id">xxxxxx</span>
</span>
<?php endforeach; ?>

</div>


This worked great for paypal! 

Any idea how to do this for the standard authorize.net plugin that comes with virtuemart?  I'm using VM 3.0.16

Studio 42

WHy adding this in your paiement ?
YOu can add it in your confirmed page.