lots0logs
1/28/2016 - 5:37 AM

WordPress :: Boutique Theme :: Simple PayPal Shopping Cart Variations Fix

WordPress :: Boutique Theme :: Simple PayPal Shopping Cart Variations Fix


if ( is_admin() && $boutique_active_plugin_name && !in_array($boutique_active_plugin_name,apply_filters('et_plugins_without_custom_panels',array('wp_ecommerce','eshop'))) ) {
	
	function my_boutique_save_details_disable() {
		remove_action( 'save_post', 'boutique_save_details', 10, 2 );
	}
	add_action( 'after_setup_theme', 'my_boutique_save_details_disable', 9 );
	
	function my_boutique_save_details( $post_id, $post ){
		global $pagenow;

		if ( 'post.php' != $pagenow ) return $post_id;

		if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
			return $post_id;

		$post_type = get_post_type_object( $post->post_type );
		if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) )
			return $post_id;

		if ( !isset( $_POST['et_settings_nonce'] ) || ! wp_verify_nonce( $_POST['et_settings_nonce'], basename( __FILE__ ) ) )
	        return $post_id;

		global $boutique_active_plugin_name;
		$active_plugin = $boutique_active_plugin_name;

		if ( $active_plugin == 'shopp' ) {
			if ( isset($_POST['et_shopp_product_id']) ) update_post_meta( $post_id, '_et_shopp_product_id', esc_attr($_POST['et_shopp_product_id']) );
		}
		if ( $active_plugin == 'wp_simple_paypal_sc' ) {
			if ( isset($_POST['et_simple_paypal_price']) ) update_post_meta( $post_id, '_et_simple_paypal_price', esc_attr($_POST['et_simple_paypal_price']) );
			if ( isset($_POST['et_simple_paypal_additional_settings']) ) update_post_meta( $post_id, '_et_simple_paypal_additional_settings', $_POST['et_simple_paypal_additional_settings'] );
		}
		if ( $active_plugin == 'cart66' ) {
			if ( isset($_POST['et_cart66_product_id'] ) ) update_post_meta( $post_id, '_et_cart66_product_id', esc_attr($_POST['et_cart66_product_id']) );
		}
	}
}

function boutique_popup_info($template_name) {
	global $boutique_active_plugin_name, $post;
	$div_name = boutique_product_name($template_name);
?>
	<div class="product_frame">
		<div id="<?php echo $div_name; ?>">
			<div class="et_popup_product_info et_<?php echo esc_attr( $boutique_active_plugin_name ); ?>">
				<?php
					do_action('boutique_popup_product_description');
					if ( in_array( $boutique_active_plugin_name,array('cart66','eshop','wp_simple_paypal_sc') ) ){
						echo '<h2 class="et_popup_title"><a href="'.esc_url( get_permalink() ).'">'.get_the_title().'</a></h2>';
						echo '<div class="et_popup_excerpt">' . get_the_excerpt() . '</div>';
					}
					do_action('boutique_popup_before_add_button');
					switch ($boutique_active_plugin_name){
						case 'shopp':
							if ( get_post_meta(get_the_ID(),'_et_shopp_product_id',true) ) echo do_shortcode('[product id="'.get_post_meta(get_the_ID(),'_et_shopp_product_id',true).'" ]');
							break;
						case 'eshop':
							#activate 'Show add to cart forms on WordPress post listings'
							global $eshopoptions;
							$eshopoptions['show_forms'] = 'yes';
							echo do_shortcode('[eshop_addtocart]');
							break;
						case 'cart66':
							echo do_shortcode('[add_to_cart item="'.get_post_meta(get_the_ID(),'_et_cart66_product_id',true).'" ]');
							break;
						case 'wp_simple_paypal_sc':
							$sc_additional_settings = get_post_meta( get_the_ID(), '_et_simple_paypal_additional_settings', true ) ? get_post_meta( get_the_ID(), '_et_simple_paypal_additional_settings', true ) : '';
							$output = apply_filters('the_content',do_shortcode('[wp_cart_button name="'.$post->post_title.'" price="'.get_post_meta(get_the_ID(),'_et_simple_paypal_price',true).'" '. esc_attr($sc_additional_settings) . ']'));
							$output = preg_replace('/"cartLink" value="([^"]+)"/','"cartLink" value="'.get_permalink(get_the_ID()).'"',$output);
							echo $output;
							break;
						case 'wp_ecommerce':
							get_template_part('wpsc-boutique_index','index');
							break;
					}
					do_action('boutique_popup_after_add_button'); ?>
			</div> <!-- end .et_popup_product_info -->
		</div> <!-- end #<?php echo $div_name; ?> -->
	</div> <!-- end .product_frame -->
<?php }