Jump to content

pigsfoot

New Members
  • Posts

    4
  • Joined

  • Last visited

pigsfoot's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Not sure how to mark as resolved... Anyway... fixed it... turns out it was the original URL variable... it had http:// where it should of just been the domain.. the rest of the script enters the http:// part
  2. Hi, Firstly, Apologies if I'm asking to much of the forum. I have been sent an example file to create an API link to a back-end system we use, unfortunately I have no experience with PHP and the file isn't working. I have asked the people who gave me the file if they can help and i just get a response of "We don't support it" When i run the script i get the following error message, i have removed the domain name from the error message as the actual file contains keys that can not be changed. The code is below, i have removed the public and secret key as they are specific to this connection and can not be changed... sorry. Just for info... the server the script is being run on is using PHO 5.5... not sure if that matters or not but i did read on another forum that some commands may be specif to the version of PHP in use. Any help on this would be very much appreciated as i have no idea where to even start. Thanks.. <?php // Enter your details here; find the Key and Secret from the excel CSV Spread sheet. //If this has not been provided to you, you will need to request this from support@purplewifi.net $public_key = 'xxx'; $private_key = 'xxx'; $domain = 'http://purpleportal.net/'; // create new api instance $api = new PurpleAPIConnection($public_key, $private_key, $domain); // run a few API calls: // first: test api; this tests the APi Function to see if it recalls back correctly. $endpoint = $api->getEndpoint('/ping'); print_r($endpoint['data']); // second: get venues; get a list of venues beneath that customer record group; APi Key & Secret. $response = $api->getEndpoint('/venues'); if ($response['data']) { print_r($response['data']['venues']); // third: grab a random venue $random = round(rand(0, count($response['data']['venues']))); $venue_id = $response['data']['venues'][$random]['id']; if ($venue_id) { // fourth: get visitors from august 1st onwards for that venue $response = $api->getEndpoint("/venue/$venue_id/visitors?from=20140801"); if ($response) { print_r($response); } } } else { echo "No venues found!\n"; print_r($response); } // portal api class class PurpleAPIConnection { protected $public_key; protected $private_key; protected $domain; protected $protocol; protected $contenttype; public function __construct($public_key, $private_key, $domain, $protocol = 'https') { $this->public_key = $public_key; $this->private_key = $private_key; $this->domain = $domain; $this->protocol = $protocol; $this->contenttype = 'application/json'; $this->ensureCurl(); } private function ensureCurl() { if (!function_exists('curl_init')) { throw new \Exception("This requires PHP's CURL library"); } } public function getEndpoint($url, $get_data = array(), $post_data = array()) { $url = '/api/company/v1' . $url; $date = new DateTime('now', new DateTimeZone('UTC')); $date = $date->format('D, d M Y H:i:s T'); $post_string = is_array($post_data) ? http_build_query($post_data) : ''; $query_string = is_array($get_data) ? http_build_query($get_data) : ''; if ($query_string) { $url .= '?' . $query_string; } $token_string = $this->contenttype . "\r\n" . $this->domain . "\r\n" . $url . "\r\n" . $date . "\r\n" . $post_string . "\r\n"; $token = hash_hmac('sha256', $token_string, $this->private_key); $headers = array( 'Content-Type: ' . $this->contenttype, 'Content-Length: ' . strlen($post_string), 'Date: ' . $date, 'X-API-Authorization: ' . $this->public_key . ':' . $token ); $url = $this->protocol . '://' . $this->domain . $url; return $this->parseResponse($this->curlRequest($url, 'GET', $headers, $post_string)); } private function parseResponse($response_string) { print "ResponseString:".$response_string; $response = json_decode($response_string, true); if (!$response) { throw new \Exception("Unexpected output:\n$response_string"); } return $response; } private function curlRequest($url, $method = 'GET', $headers = array(), $post_string = '') { $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); if (is_array($headers)) { curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); } return curl_exec($ch); } }
  3. HI, I have a wordpress site that uses WooCommerce and also WooThemes "Wish list" extension as part of a shop. I am wanting to hide the "add to cart" button when a price is 0.00 but retain the "Add to Wish List" button. I have already spoken to WooThemes and there responce is they do not offer coding assistance, i would have to employee someone to look at this for me.. I do have some code that kind of works... in that it does hide the "add to cart" button but it also hides the "add to wish list" button <?php /* * Swop the 'Free!' price notice and hide the cart with 'Subscription Item' in WooCommerce */ add_filter( 'woocommerce_variable_free_price_html', 'hide_free_price_notice' ); add_filter( 'woocommerce_free_price_html', 'hide_free_price_notice' ); add_filter( 'woocommerce_variation_free_price_html', 'hide_free_price_notice' ); function hide_free_price_notice( $price ) { remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 ); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 ); return 'Subscription Item'; } ?> I'm no programmer so i have no idea if this is a complex fix or something that maybe you guys on a forum can help out with. If it's out of the scope of general foum help i will have to post a job somewhere to see if i can get some help that way. Many Thanks...
  4. Hi I have some code within an ecommerce shop that i'm using as follows <?php _e('No products found','woocommerce'); ?></p> Is it possible to replace the text 'No products found' with something that allows me to display some text, a hyperlink and also an image. I just want to format the message better. Many Thanks..
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.