Subversion Repositories cheapmusic

Rev

Rev 23 | Rev 27 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 23 Rev 24
Line 5... Line 5...
5
 
5
 
6
// Get CJ Affiliate listings
6
// Get CJ Affiliate listings
7
function get_cjaffiliate($query, $searchType) {
7
function get_cjaffiliate($query, $searchType) {
8
    $vendors = Vendors::getInstance();
8
    $vendors = Vendors::getInstance();
9
    $config = $vendors->getVendor(Vendors::CJAFFILIATE);
9
    $config = $vendors->getVendor(Vendors::CJAFFILIATE);
10
 
-
 
11
    $flatShipping = array (
-
 
12
        "4258829"=>"2.98",  // Barnes & Noble
-
 
13
        "129899"=>"3.00",   // Booksamillion.com
-
 
14
        "4911961"=>"3.24",  // FYE.com
-
 
15
        "4926671"=>"3.99",  // Secondspin.com
-
 
16
        "1111879"=>"2.99",  // ArkivMusic
-
 
17
        "5153127"=>"0.00",  // OnBuy.com
-
 
18
        "1595844"=>"0.00"   // Sheet Music Plus
-
 
19
    );
-
 
20
 
10
 
21
// API request variables
11
// API request variables
22
    $query = '+' . str_replace(" ", " +", $query); // enforce 'and' logic
12
    $query = '+' . str_replace(" ", " +", $query); // enforce 'and' logic
23
	$safequery = urlencode($query);
13
	$safequery = urlencode($query);
24
	$numResults = $config['numResults'];
14
	$numResults = $config['numResults'];
Line 100... Line 90...
100
			}
90
			}
101
 
91
 
102
			switch ($merchantId) {
92
			switch ($merchantId) {
103
			    case 4911961: // FYE.com
93
			    case 4911961: // FYE.com
104
    				$category = "CD";
94
    				$category = "CD";
-
 
95
       			    $freeShippingCap = 40.00;
-
 
96
           			$handlingTime = 1;
-
 
97
           			$shippingCost = 3.24;
-
 
98
           			$shippingCurrency = 'USD';
105
    				if (preg_match('/\d\d\d\d$/', $title)) {
99
    				if (preg_match('/\d\d\d\d$/', $title)) {
106
                        $type = 'USED';
100
                        $type = 'Used';
107
    				    $condition = "Used";
101
    				    $condition = "Used";
108
    				    $title = rtrim(substr($title, 0, -4));
102
    				    $title = rtrim(substr($title, 0, -4));
109
    				} else {
103
    				} else {
110
                        $type = 'NEW';
104
                        $type = 'New';
111
    				    $condition = "Brand New";
105
    				    $condition = "Brand New";
112
    				}
106
    				}
113
    				break;
107
    				break;
114
    				
108
    				
115
   				case 4926671: // Secondspin.com
109
   				case 4926671: // Secondspin.com
-
 
110
       			    $freeShippingCap = 0.00;
-
 
111
           			$handlingTime = 1;
-
 
112
           			$shippingCost = 3.99;
-
 
113
           			$shippingCurrency = 'USD';
116
                    $type = 'USED';
114
                    $type = 'Used';
117
   				    $condition = "Used";
115
   				    $condition = "Used";
118
    				$category = "CD";
116
    				$category = "CD";
119
    				break;
117
    				break;
120
    				
118
    				
121
    			case 1595844: // Sheet Music Plus
119
    			case 1595844: // Sheet Music Plus
-
 
120
       			    $freeShippingCap = 35.00;
-
 
121
           			$handlingTime = 1;
-
 
122
           			$shippingCost = 3.99;
-
 
123
           			$shippingCurrency = 'USD';
122
                    $type = 'NEW';
124
                    $type = 'New';
123
   				    $condition = "Brand New";
125
   				    $condition = "Brand New";
124
    				$category = "Book";
126
    				$category = "Book";
125
    				break;
127
    				break;
126
    				
128
    				
127
    			case 1111879: // ArkivMusic
129
    			case 1111879: // ArkivMusic
-
 
130
       			    $freeShippingCap = 0.00;
-
 
131
           			$handlingTime = 1;
-
 
132
           			$shippingCost = 2.99;
-
 
133
           			$shippingCurrency = 'USD';
128
                    $type = 'NEW';
134
                    $type = 'New';
129
   				    $condition = "Brand New";
135
   				    $condition = "Brand New";
130
    				$category = "CD";
136
    				$category = "CD";
131
    				break;
137
    				break;
132
 
138
 
133
   				default:
139
   				default:
-
 
140
       			    $freeShippingCap = 0.00;
-
 
141
           			$handlingTime = -1;
-
 
142
           			$shippingCost = 0.00;
-
 
143
           			$shippingCurrency = 'USD';
134
                    $type = 'USED';
144
                    $type = 'Used';
135
   				    $condition = "Used";
145
   				    $condition = "Used";
136
    				$category = "CD";
146
    				$category = "CD";
137
    				break;
147
    				break;
138
			}
148
			}
139
 
149
 
Line 159... Line 169...
159
			$location = 'US';
169
			$location = 'US';
160
			$zip = '';
170
			$zip = '';
161
			$feedbackScore = -1;
171
			$feedbackScore = -1;
162
			$feedbackPercent = -1;
172
			$feedbackPercent = -1;
163
			$sellerName = '';
173
			$sellerName = '';
164
			$handlingTime = -1;
-
 
165
			$shippingCost = $flatShipping[$merchantId];
-
 
166
			$shippingCurrency = 'USD';
-
 
167
 
174
 
168
// bugbug
175
// bugbug
169
//ls_cj_csv(array((string)$product->{'advertiser-name'},(string)$product->{'advertiser-category'},(string)$product->{'name'},(string)$product->{'description'},"'".$barcode,$barcodeType,minNotNull(array($product->{'price'},(string)$product->{'sale-price'})),(string)$product->{'buy-url'}));
176
//ls_cj_csv(array((string)$product->{'advertiser-name'},(string)$product->{'advertiser-category'},(string)$product->{'name'},(string)$product->{'description'},"'".$barcode,$barcodeType,minNotNull(array($product->{'price'},(string)$product->{'sale-price'})),(string)$product->{'buy-url'}));
170
 
177
 
171
            // this is last after all checks
178
            // this is last after all checks
Line 174... Line 181...
174
			    continue;
181
			    continue;
175
			}
182
			}
176
 
183
 
177
			$arr[] = array(
184
			$arr[] = array(
178
				"Merchant" => $merchantName,
185
				"Merchant" => $merchantName,
179
				"Type" => ($searchType == constant("NEW") ? 'New' : 'Used'),
186
				"Type" => "$type",
180
				"Title" => "$title",
187
				"Title" => "$title",
181
				"Barcode" => "$barcode",
188
				"Barcode" => "$barcode",
182
				"BarcodeType" => "$barcodeType",
189
				"BarcodeType" => "$barcodeType",
183
				"Image" => "$pic",
190
				"Image" => "$pic",
184
				"URL" => "$url",
191
				"URL" => "$url",
Line 196... Line 203...
196
				"FeedbackPercent" => "$feedbackPercent",
203
				"FeedbackPercent" => "$feedbackPercent",
197
				"SellerName" => "$sellerName",
204
				"SellerName" => "$sellerName",
198
				"HandlingTime" => "$handlingTime",
205
				"HandlingTime" => "$handlingTime",
199
				"ShippingCost" => "$shippingCost",
206
				"ShippingCost" => "$shippingCost",
200
				"ShippingCurrency" => "$shippingCurrency",
207
				"ShippingCurrency" => "$shippingCurrency",
-
 
208
				"FreeShippingCap" => "$freeShippingCap",
201
				"Show" => true
209
				"Show" => true
202
			);
210
			);
203
		}
211
		}
204
	}
212
	}
205
// If the response does not indicate 'Success,' log an error
213
// If the response does not indicate 'Success,' log an error