woocommerce/classes/integrations/shareyourcart/class-shareyourcart-woocomm...

108 lines
2.3 KiB
PHP
Raw Normal View History

<?php
2013-03-22 18:29:36 +00:00
require_once( "class.shareyourcart-wp-woocommerce.php" );
2013-03-22 18:29:36 +00:00
/**
* ShareYourCartWooCommerceEx class.
*
* @extends ShareYourCartWooCommerce
*/
class ShareYourCartWooCommerceEx extends ShareYourCartWooCommerce {
public $settings;
/**
2013-03-22 18:29:36 +00:00
* __construct function.
*
* @access public
* @param mixed $settings
* @return void
*/
function __construct( $settings ) {
$this->settings = $settings;
2013-03-22 18:29:36 +00:00
// disable analytics for the woocommerce integration
$this->SDK_ANALYTICS = false;
parent::__construct();
}
2012-11-27 16:22:47 +00:00
2013-03-22 18:29:36 +00:00
/**
* Since this class has loaded, the WooCommerce plugin is active.
*
* @access public
* @return bool
*/
public function isCartActive() {
2013-03-22 18:29:36 +00:00
return true;
}
2012-11-27 16:22:47 +00:00
2013-03-22 18:29:36 +00:00
/**
* getSecretKey function.
*
* @access public
* @return string
*/
public function getSecretKey() {
return '2cfd496d-7812-44ba-91ce-e43c59f6c680';
}
2012-11-27 16:22:47 +00:00
/**
2013-03-22 18:29:36 +00:00
* Since we have already integrated this in our own settings page, leave this function empty.
*
2013-03-22 18:29:36 +00:00
* @access public
* @return void
*/
public function showAdminMenu() {}
/**
* Set the field value
*
2013-03-22 18:29:36 +00:00
* @access protected
* @param mixed $field
* @param mixed $value
* @return void
*/
2013-03-22 18:29:36 +00:00
protected function setConfigValue( $field, $value ) {
2012-11-27 16:22:47 +00:00
2013-03-22 18:29:36 +00:00
$this->settings[ $field ] = $value;
//make sure to update the enabled field as well, based on the account_status
2013-03-22 18:29:36 +00:00
switch( $field ){
case 'account_status':
$this->settings['enabled'] = ( $value == 'active' ? 'yes' : 'no' );
2013-03-22 18:29:36 +00:00
break;
case "plugin_current_version":
2013-03-03 17:07:31 +00:00
//this setting needs to be set globally as well, in order to be recognized by other ShareYourCart integrations,
//and to not interfere with one-another
2013-03-22 18:29:36 +00:00
parent::setConfigValue( $field, $value );
break;
}
2012-11-27 16:22:47 +00:00
//save the config in the DB
2012-11-27 16:22:47 +00:00
update_option( 'woocommerce_shareyourcart_settings', $this->settings );
}
2012-11-27 16:22:47 +00:00
/**
* Get the field value
*
2013-03-22 18:29:36 +00:00
* @access protected
* @param mixed $field
* @return string
*/
protected function getConfigValue( $field ) {
2013-03-22 18:29:36 +00:00
$value = ( isset( $this->settings[ $field ] ) ) ? $this->settings[ $field ] : '';
2012-11-27 16:22:47 +00:00
2013-03-22 18:29:36 +00:00
// search for the global value of this field
// as it might have been changed by an external ShareYourCart integration
if ( $field == "plugin_current_version" ) {
$val = parent::getConfigValue( $field );
2012-11-27 16:22:47 +00:00
2013-03-22 18:29:36 +00:00
if ( ! empty( $val ) )
$value = $val;
}
2012-11-27 16:22:47 +00:00
return $value;
}
}