Changeset 587383
- Timestamp:
- 08/19/2012 11:47:12 AM (14 years ago)
- Location:
- wpcb/trunk
- Files:
-
- 2 edited
-
index.php (modified) (4 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wpcb/trunk/index.php
r586137 r587383 5 5 Plugin URI: http://wpcb.fr 6 6 Description: Plugin de paiement par CB, paypal, ... et de calcul de frais de port (WP e-Commerce requis) 7 Version: 2.3.1 07 Version: 2.3.11 8 8 Author: 6WWW 9 9 Author URI: http://6www.net … … 139 139 add_settings_field('googleemail','Email Google Drive (ou Google App)','wpcb_googleemail_callback','wpcb_general','general_settings_section',array('description' )); 140 140 add_settings_field('googlepassword','Password associé Gmail ou Google Apps','wpcb_googlepassword_callback','wpcb_general','general_settings_section',array('description' )); 141 add_settings_field('spreadsheetKey','spreadsheetKey','wpcb_spreadsheetKey_callback','wpcb_general','general_settings_section',array('description' )); 141 add_settings_field('spreadsheetKey','spreadsheetKey for log','wpcb_spreadsheetKey_callback','wpcb_general','general_settings_section',array('description' )); 142 add_settings_field('AddSalesCheckbox','Add Sales to Google spreadsheet','wpcb_AddSalesCheckbox_callback','wpcb_general','general_settings_section',array('The sales will be added to your google spreadsheet' )); 143 add_settings_field('AllSales_spreadsheetKey','spreadsheetKey for All Sales','wpcb_AllSales_spreadsheetKey_callback','wpcb_general','general_settings_section',array('description' )); 144 add_settings_field('AddSalesNotificationCheckbox','Notify me when a Sales is added to Google spreadsheet','wpcb_AddSalesNotificationCheckbox_callback','wpcb_general','general_settings_section',array('You will get an email when a sale is added to Google spreadsheet' )); 145 142 146 register_setting('wpcb_general','wpcb_general'); 143 147 } … … 294 298 echo '<input type="text" size="75"id="spreadsheetKey" name="wpcb_general[spreadsheetKey]" value="' . $val . '" />'; 295 299 } 296 300 301 function wpcb_AddSalesCheckbox_callback($args){ 302 $options = get_option( 'wpcb_general'); 303 $html = '<input type="checkbox" id="AddSalesCheckbox" name="wpcb_general[AddSalesCheckbox]" value="1" ' . checked(1, $options['AddSalesCheckbox'], false) . '/>'; 304 $html .= '<label for="AddSalesCheckbox"> ' . $args[0] . '</label>'; 305 echo $html; 306 } 307 308 function wpcb_AllSales_spreadsheetKey_callback(){ 309 $options = get_option( 'wpcb_general'); 310 $val = '0AkLWPxefL-fydENzRXpjdEk0OVBsQ2ZmYWFrMGp3QVE'; 311 if(isset($options['AllSales_spreadsheetKey'])){$val = $options['AllSales_spreadsheetKey'];} 312 echo '<input type="text" size="75" id="AllSales_spreadsheetKey" name="wpcb_general[AllSales_spreadsheetKey]" value="' . $val . '" />'; 313 } 314 315 function wpcb_AddSalesNotificationCheckbox_callback($args){ 316 $options = get_option( 'wpcb_general'); 317 $html = '<input type="checkbox" id="AddSalesNotificationCheckbox" name="wpcb_general[AddSalesNotificationCheckbox]" value="1" ' . checked(1, $options['AddSalesNotificationCheckbox'], false) . '/>'; 318 $html .= '<label for="AddSalesNotificationCheckbox"> ' . $args[0] . '</label>'; 319 echo $html; 320 } 297 321 298 322 /** … … 1747 1771 } 1748 1772 1773 $wpcb_general = get_option( 'wpcb_general'); 1774 if ($wpcb_general['AddSalesCheckbox']){ 1775 add_action('wpsc_confirm_checkout','AddSaleToGoogleSpreadsheet'); 1776 } 1777 1778 1779 function AddSaleToGoogleSpreadsheet($purchase_log_id){ 1780 // This is triggered when a sales is completed and also when the state is change to Completed in the admin 1781 global $wpdb; 1782 $purchase_log = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id`= %s LIMIT 1", $purchase_log_id ), ARRAY_A ); 1783 $is_transaction = wpsc_check_purchase_processed($purchase_log['processed']); 1784 $debug.='$purchase_log_id='.$purchase_log_id."\r\n"; 1785 $debug.='$is_transaction='.$is_transaction."\r\n"; 1786 1787 $wpcb_general = get_option( 'wpcb_general'); 1788 //print_r($wpcb_general); 1789 1790 $email_a = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_SUBMITED_FORM_DATA."` WHERE log_id=".$purchase_log_id." AND form_id=9 LIMIT 1",ARRAY_A); 1791 $lastname_a = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_SUBMITED_FORM_DATA."` WHERE log_id=".$purchase_log_id." AND form_id=3 LIMIT 1",ARRAY_A) ; 1792 $firstname_a = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_SUBMITED_FORM_DATA."` WHERE log_id=".$purchase_log_id." AND form_id=2 LIMIT 1",ARRAY_A) ; 1793 $email=$email_a['value'];$firstname=$firstname_a['value'];$lastname=$lastname_a['value']; 1794 $purchase = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE id=".$purchase_log_id." LIMIT 1",ARRAY_A); 1795 $cart = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid` = '{$purchase_log_id}'" , ARRAY_A ); 1796 $detail=''; 1797 if ( $cart != null) { 1798 foreach ( $cart as $row ) { 1799 $detail.=$row['quantity'].'x '.$row['name'].'('.$row['price'].' p.u.) & '; 1800 } 1801 //$row['name'] $row['price'] 1802 } 1803 $detail=substr($detail, 0, -3); 1804 1805 $rowData=array('purchase'=>$purchase_log_id,'email'=>$email,'nom'=>$lastname,'firstname'=>$firstname,'totalprice'=>$purchase['totalprice'],'gateway'=>$purchase['gateway'],'promocode'=>$purchase['discount_data'],'discount'=>$purchase['discount_value'],'cart'=>$detail,'processed'=>$purchase['processed']); 1806 $debug.='Content of new item in the spreadsheet ->'."\r\n"; 1807 foreach ($rowData as $key=>$value){ 1808 $debug.=$key.'=>'.$value. "\r\n"; 1809 } 1810 1811 //Add to Sales in google doc using Zend : 1812 if (WP_ZEND_FRAMEWORK){ 1813 $service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME; 1814 $client = Zend_Gdata_ClientLogin::getHttpClient($wpcb_general['googleemail'], $wpcb_general['googlepassword'], $service); 1815 $spreadsheetService = new Zend_Gdata_Spreadsheets($client); 1816 1817 // Document Query : 1818 $query_worksheet = new Zend_Gdata_Spreadsheets_DocumentQuery(); 1819 $query_worksheet->setSpreadsheetKey($wpcb_general['AllSales_spreadsheetKey']); 1820 $feed = $spreadsheetService->getWorksheetFeed($query_worksheet); 1821 // Par default : Sheet1 : 1822 foreach($feed->entries as $entry){ 1823 $worksheetId=basename($entry->id); 1824 break; 1825 } 1826 // Ensuite on cherche si Sales exist pas 1827 foreach($feed->entries as $entry){ 1828 if ($entry->title->text=='Sales'){$worksheetId=basename($entry->id);} 1829 } 1830 1831 // LIst Query : 1832 $query = new Zend_Gdata_Spreadsheets_ListQuery(); 1833 $query->setSpreadsheetKey($wpcb_general['AllSales_spreadsheetKey']); 1834 //$worksheetId='od6'; 1835 $query->setWorksheetId($worksheetId); 1836 $query->setSpreadsheetQuery('purchase='.$purchase_log_id); 1837 $listFeed = $spreadsheetService->getListFeed($query); 1838 $already_exist=false; 1839 foreach ($listFeed->entries as $listFeed_entry){ 1840 $CurrentrowData = $listFeed_entry->getCustom(); 1841 $debug.='It already exists with the old values : '; 1842 foreach($CurrentrowData as $customEntry) { 1843 $debug.=$customEntry->getColumnName() . " = " . $customEntry->getText(). "\r\n"; 1844 //echo '<pre>'.$customEntry->getColumnName() . " = " . $customEntry->getText().'</pre>'; 1845 } 1846 $already_exist=true; 1847 $updatedListEntry = $spreadsheetService->updateRow($listFeed_entry,$rowData); 1848 $debug = 'A sale has been updated.'."\r\n\r\n".$debug; 1849 } 1850 if (!$already_exist){ 1851 // Insert : 1852 $debug = 'A new sale has been added !'."\r\n\r\n".$debug; 1853 $insertedListEntry = $spreadsheetService->insertRow($rowData,$wpcb_general['AllSales_spreadsheetKey'],$worksheetId); 1854 } 1855 } 1856 if ($wpcb_general['AddSalesNotificationCheckbox']){ 1857 wp_mail($wpcb_general['googleemail'],'Notification from WPCB',$debug); 1858 } 1859 } 1860 1861 1749 1862 ?> -
wpcb/trunk/readme.txt
r586137 r587383 6 6 Requires at least: 2.7 7 7 Tested up to: 3.4.1 8 Stable tag: 2.3.1 08 Stable tag: 2.3.11 9 9 10 10 Paiement par cartes bancaires (majoritée des banques françaises), paypal, chèques et virement pour le plugin WP e-Commerce. … … 46 46 47 47 Toutes les ventes s'ajoutent dans votre tableau de bord Trello ! 48 49 = Ajout dans google spreadsheet = 50 51 Toutes les ventes s'ajoutent dans votre tableau google spreadsheet (excel en ligne) ! 48 52 49 53 = Affichage du nombre de ventes = … … 205 209 206 210 == Changelog == 211 212 = 2.3.11 = 213 * Toutes les ventes réussies s'ajoutent dans le tableau google spreadsheet 207 214 208 215 = 2.3.10 =
Note: See TracChangeset
for help on using the changeset viewer.