我有一个Wordpress商店设置,并且有一个挂钩被调用以显示客户选择的产品选项。
钩子是:
wpsc_after_cart_widget_item_name
<?php echo wpsc_cart_item_name(); ?></a>
<span style="font-size: 10px; line-height: 0.06em;">
<?php do_action ( "wpsc_after_cart_widget_item_name" ); ?></td>
<td><?php echo wpsc_cart_item_quantity(); ?></td>
<td><?php echo wpsc_cart_item_price(); ?></td>
<td class="cart-widget-remove"><form action="" method="post" class="adjustform">
<input type="hidden" name="quantity" value="0" />
<input type="hidden" name="key"
value="<?php echo wpsc_the_cart_item_key(); ?>" />
<input type="hidden" name="wpsc_update_quantity" value="true" />
<input class="remove_button" type="submit" />
我无法弄清楚它在购物车小部件中显示两次的原因。我已经彻底搜索过滤器钩子,故障排除,甚至用jQuery删除重复文本的丑陋方式,但没有找到任何内容。
任何帮助将不胜感激。我的网站是http://www.a1decals.com/products-page。
我无法发布图片,但这里有一个链接:http://i134.photobucket.com/albums/q87/mad_stallion_2006/screen001-3_zpsa94e087b.jpg
更新:这是购物车的代码,您的代码插入到您告诉我依赖的动作挂钩的上方和下方。
我不确定我是否将代码放在错误的位置或者是什么,我将继续移动它以查看,但我仍然不知所措。
很抱歉提出所有代码,但我不知道可能相关的内容。
<?php global $wpsc_cart, $wpdb, $wpsc_checkout, $wpsc_gateway, $wpsc_coupons, $wpsc_registration_error_messages;
$wpsc_checkout = new wpsc_checkout();
$wpsc_gateway = new wpsc_gateways();
$alt = 0;
$coupon_num = wpsc_get_customer_meta( 'coupon' );
if( $coupon_num )
$wpsc_coupons = new wpsc_coupons( $coupon_num );
if(wpsc_cart_item_count() < 1) :
_e('Oops, there is nothing in your cart.', 'wpsc') . "<a href=" . esc_url( get_option( "product_list_url" ) ) . ">" . __('Please visit our shop', 'wpsc') . "</a>";
return;
endif;
?>
<div id="checkout_page_container"><br>
<h3><?php _e('', 'wpsc'); ?></h3></span>
<table class="checkout_cart">
<tr class=" header">
<p style="font-family: Verdana, Arial, Helvetica, sans-serif; line-height: normal; text-align: center;"><span style="text-decoration: underline; color: #f4f4f4;"><span style="font-size: 18px;">Cart Records "Product Options" Like Color And Mirror Twice For Us </p>
<tr style="background-color: #000078;">
<th colspan="2"><?php _e('Product', 'wpsc'); ?></th>
<th><?php _e('Quantity', 'wpsc'); ?></th>
<th><?php _e('Price', 'wpsc'); ?></th>
<th><?php _e('Total', 'wpsc'); ?></th>
<th> </th>
</tr>
<?php while (wpsc_have_cart_items()) : wpsc_the_cart_item(); ?>
<?php
$alt++;
if ($alt %2 == 1)
$alt_class = 'alt';
else
$alt_class = '';
?>
<?php //this displays the confirm your order html ?>
<?php // This is used to fix the hook being called twice incorrectly ?>
<?php global $receivedItemHooks ?>
<?php if (!$receivedItemHooks) $receivedItemHooks = array() ?>
<?php if (!isset($receivedItemHooks[wpsc_the_cart_item_key()]): ?>
<?php do_action ( "wpsc_before_checkout_cart_row" ); ?>
<tr class="product_row product_row_<?php echo wpsc_the_cart_item_key(); ?> <?php echo $alt_class;?>">
<td class="firstcol wpsc_product_image wpsc_product_image_<?php echo wpsc_the_cart_item_key(); ?>">
<?php if('' != wpsc_cart_item_image()): ?>
<?php do_action ( "wpsc_before_checkout_cart_item_image" ); ?>
<img src="<?php echo wpsc_cart_item_image(); ?>" alt="<?php echo wpsc_cart_item_name(); ?>" title="<?php echo wpsc_cart_item_name(); ?>" class="product_image" />
<?php do_action ( "wpsc_after_checkout_cart_item_image" ); ?>
<?php else:
/* I dont think this gets used anymore,, but left in for backwards compatibility */
?>
<div class="item_no_image">
<?php do_action ( "wpsc_before_checkout_cart_item_image" ); ?>
<a href="<?php echo esc_url( wpsc_the_product_permalink() ); ?>">
<span><?php _e('No Image','wpsc'); ?></span>
</a>
<?php do_action ( "wpsc_after_checkout_cart_item_image" ); ?>
</div>
<?php endif; ?>
</td>
<td class="wpsc_product_name wpsc_product_name_<?php echo wpsc_the_cart_item_key(); ?>">
<?php do_action ( "wpsc_before_checkout_cart_item_name" ); ?>
<a href="<?php echo esc_url( wpsc_cart_item_url() );?>">
<span style="font-size: 12px;">
<?php echo wpsc_cart_item_name(); ?></a>
<span style="font-size: 12px;">
<?php do_action ( "wpsc_after_checkout_cart_item_name" ); ?>
</td>
<td class="wpsc_product_quantity wpsc_product_quantity_<?php echo wpsc_the_cart_item_key(); ?>">
<form action="<?php echo esc_url( get_option( 'shopping_cart_url' ) ); ?>" method="post" class="adjustform qty">
<input type="text" name="quantity" size="2" value="<?php echo wpsc_cart_item_quantity(); ?>" />
<input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>" />
<input type="hidden" name="wpsc_update_quantity" value="true" />
<input type="submit" value="<?php _e('Update', 'wpsc'); ?>" name="submit" />
</form>
</td>
<td><?php echo wpsc_cart_single_item_price(); ?></td>
<td class="wpsc_product_price wpsc_product_price_<?php echo wpsc_the_cart_item_key(); ?>"><span class="pricedisplay"><?php echo wpsc_cart_item_price(); ?></span></td>
<td class="wpsc_product_remove wpsc_product_remove_<?php echo wpsc_the_cart_item_key(); ?>">
<form action="<?php echo esc_url( get_option( 'shopping_cart_url' ) ); ?>" method="post" class="adjustform remove">
<input type="hidden" name="quantity" value="0" />
<input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>" />
<input type="hidden" name="wpsc_update_quantity" value="true" />
<input type="submit" value="<?php _e('Remove', 'wpsc'); ?>" name="submit" />
<?php // Mark the item as rendered ?>
<?php $receivedItemHooks[wpsc_the_cart_item_key()] = true ?>
<?php endif ?>
</form>
</td>
</tr>
<?php do_action ( "wpsc_after_checkout_cart_row" ); ?>
<?php endwhile; ?>
<?php //this HTML displays coupons if there are any active coupons to use ?>
<?php
if(wpsc_uses_coupons()): ?>
<?php if(wpsc_coupons_error()): ?>
<tr class="wpsc_coupon_row wpsc_coupon_error_row"><td colspan="6"><?php _e('Coupon is not valid.', 'wpsc'); ?></td></tr>
<?php endif; ?>
<tr class="wpsc_coupon_row">
<td colspan="2"><?php _e('Enter coupon code :', 'wpsc'); ?></td>
<td colspan="4" class="coupon_code">
<form method="post" action="<?php echo esc_url( get_option( 'shopping_cart_url' ) ); ?>">
<input type="text" name="coupon_num" id="coupon_num" value="<?php echo $wpsc_cart->coupons_name; ?>" />
<input type="submit" value="<?php _e('Update', 'wpsc') ?>" />
</form>
</td>
</tr>
<tr class="wpsc_total_before_shipping">
<td colspan="3"><?php _e('Cost before shipping:','wpsc'); ?></td>
<td colspan="3" class="wpsc_total_amount_before_shipping"><?php echo wpsc_cart_total_widget(false,false,false);?></td>
</tr>
<?php endif; ?>
</table>
<!-- cart contents table close -->
<?php if(wpsc_uses_shipping()): ?>
<p class="wpsc_cost_before"></p>
<?php endif; ?>
<?php //this HTML dispalys the calculate your order HTML ?>
<?php if(wpsc_has_category_and_country_conflict()): ?>
<p class='validation-error'><?php echo esc_html( wpsc_get_customer_meta( 'category_shipping_conflict' ) ); ?></p>
<?php endif; ?>
<?php if(isset($_SESSION['WpscGatewayErrorMessage']) && $_SESSION['WpscGatewayErrorMessage'] != '') :?>
<p class="validation-error"><?php echo $_SESSION['WpscGatewayErrorMessage']; ?></p>
<?php
endif;
?>
<?php do_action('wpsc_before_shipping_of_shopping_cart'); ?>
<div id="wpsc_shopping_cart_container">
<?php if(wpsc_uses_shipping()) : ?>
<h2><font color="#1956cf"><?php _e('Calculate Shipping Price', 'wpsc'); ?></font></h2>
<table class="productcart">
<tr class="wpsc_shipping_info">
<td colspan="5">
<?php _e('Please specify shipping location below to calculate your shipping costs', 'wpsc'); ?>
</td>
</tr>
<?php if (!wpsc_have_shipping_quote()) : // No valid shipping quotes ?>
<?php if (wpsc_have_valid_shipping_zipcode()) : ?>
<tr class='wpsc_update_location'>
<td colspan='5' class='shipping_error' >
<?php _e('Please provide a Zipcode and click Calculate in order to continue.', 'wpsc'); ?>
</td>
</tr>
<?php else: ?>
<tr class='wpsc_update_location_error'>
<td colspan='5' class='shipping_error' >
<?php _e('Sorry, online ordering is unavailable to this destination and/or weight. Please double check your destination details.', 'wpsc'); ?>
</td>
</tr>
<?php endif; ?>
<?php endif; ?>
<tr class='wpsc_change_country'>
<td colspan='5'>
<form name='change_country' id='change_country' action='' method='post'>
<?php echo wpsc_shipping_country_list();?>
<input type='hidden' name='wpsc_update_location' value='true' />
<input type='submit' name='wpsc_submit_zipcode' value='<?php esc_attr_e( 'Calculate', 'wpsc' ); ?>' />
</form>
</td>
</tr>
<?php if (wpsc_have_morethanone_shipping_quote()) :?>
<?php while (wpsc_have_shipping_methods()) : wpsc_the_shipping_method(); ?>
<?php if (!wpsc_have_shipping_quotes()) { continue; } // Don't display shipping method if it doesn't have at least one quote ?>
<tr class='wpsc_shipping_header'><td class='shipping_header' colspan='5'><?php echo wpsc_shipping_method_name().__(' - Choose a Shipping Rate', 'wpsc'); ?> </td></tr>
<?php while (wpsc_have_shipping_quotes()) : wpsc_the_shipping_quote(); ?>
<tr class='<?php echo wpsc_shipping_quote_html_id(); ?>'>
<td class='wpsc_shipping_quote_name wpsc_shipping_quote_name_<?php echo wpsc_shipping_quote_html_id(); ?>' colspan='3'>
<label for='<?php echo wpsc_shipping_quote_html_id(); ?>'><?php echo wpsc_shipping_quote_name(); ?></label>
</td>
<td class='wpsc_shipping_quote_price wpsc_shipping_quote_price_<?php echo wpsc_shipping_quote_html_id(); ?>' style='text-align:center;'>
<label for='<?php echo wpsc_shipping_quote_html_id(); ?>'><?php echo wpsc_shipping_quote_value(); ?></label>
</td>
<td class='wpsc_shipping_quote_radio wpsc_shipping_quote_radio_<?php echo wpsc_shipping_quote_html_id(); ?>' style='text-align:center;'>
<?php if(wpsc_have_morethanone_shipping_methods_and_quotes()): ?>
<input type='radio' id='<?php echo wpsc_shipping_quote_html_id(); ?>' <?php echo wpsc_shipping_quote_selected_state(); ?> onclick='switchmethod("<?php echo wpsc_shipping_quote_name(); ?>", "<?php echo wpsc_shipping_method_internal_name(); ?>")' value='<?php echo wpsc_shipping_quote_value(true); ?>' name='shipping_method' />
<?php else: ?>
<input <?php echo wpsc_shipping_quote_selected_state(); ?> disabled='disabled' type='radio' id='<?php echo wpsc_shipping_quote_html_id(); ?>' value='<?php echo wpsc_shipping_quote_value(true); ?>' name='shipping_method' />
<?php wpsc_update_shipping_single_method(); ?>
<?php endif; ?>
</td>
</tr>
<?php endwhile; ?>
<?php endwhile; ?>
<?php endif; ?>
<?php wpsc_update_shipping_multiple_methods(); ?>
<?php if (!wpsc_have_shipping_quote()) : // No valid shipping quotes ?>
</table>
</div>
</div>
<?php return; ?>
<?php endif; ?>
</table>
<?php endif; ?>
<?php
$wpec_taxes_controller = new wpec_taxes_controller();
if($wpec_taxes_controller->wpec_taxes_isenabled()):
?>
<table class="productcart">
<tr class="total_price total_tax">
<td colspan="3">
<?php echo wpsc_display_tax_label(true); ?>
</td>
<td colspan="2">
<span id="checkout_tax" class="pricedisplay checkout-tax"><?php echo wpsc_cart_tax(); ?></span>
</td>
</tr>
</table>
<?php endif; ?>
<?php do_action('wpsc_before_form_of_shopping_cart'); ?>
<?php if( ! empty( $wpsc_registration_error_messages ) ): ?>
<p class="validation-error">
<?php
foreach( $wpsc_registration_error_messages as $user_error )
echo $user_error."<br />\n";
?>
<?php endif; ?>
<?php if ( wpsc_show_user_login_form() && !is_user_logged_in() ): ?>
<p><?php _e('You must sign in or register with us to continue with your purchase', 'wpsc');?></p>
<!--SOCIAL MEDIA CONNECT BUTTONS-->
<div>
<br>Make It Easy With Facebook and Twitter Connect. <br>
<a href="http://a1decals.com/wp-login.php?loginFacebook=1&redirect=http://a1decals.com" onclick="window.location = 'http://a1decals.com/wp-login.php?loginFacebook=1&redirect='+window.location.href; return false;"> <img src="http://a1decals.com/wp-content/uploads/2013/02/facebook_connect1.png" /> </a>
<a href="http://a1decals.com/wp-login.php?loginTwitter=1&redirect=http://a1decals.com" onclick="window.location = 'http://a1decals.com/wp-login.php?loginTwitter=1&redirect='+window.location.href; return false;"> <img src="http://a1decals.com/wp-content/uploads/2013/02/twitter_connect_button.gif" /> </a></div>
<div class="wpsc_registration_form">
<fieldset class='wpsc_registration_form'>
<h2><?php _e( 'Sign in', 'wpsc' ); ?></h2>
<?php
$args = array(
'remember' => false,
'redirect' => home_url( $_SERVER['REQUEST_URI'] )
);
wp_login_form( $args );
?>
<div class="wpsc_signup_text"><?php _e('If you have bought from us before please sign in here to purchase', 'wpsc');?></div>
</fieldset>
</div>
<?php endif; ?>
<table class='wpsc_checkout_table wpsc_checkout_table_totals'>
<?php if(wpsc_uses_shipping()) : ?>
<tr class="total_price total_shipping">
<td class='wpsc_totals'>
<?php _e('Total Shipping:', 'wpsc'); ?>
</td>
<td class='wpsc_totals'>
<span id="checkout_shipping" class="pricedisplay checkout-shipping"><?php echo wpsc_cart_shipping(); ?></span>
</td>
</tr>
<?php endif; ?>
<?php if(wpsc_uses_coupons() && (wpsc_coupon_amount(false) > 0)): ?>
<tr class="total_price">
<td class='wpsc_totals'>
<?php _e('Discount:', 'wpsc'); ?>
</td>
<td class='wpsc_totals'>
<span id="coupons_amount" class="pricedisplay"><?php echo wpsc_coupon_amount(); ?></span>
</td>
</tr>
<?php endif ?>
<tr class='total_price'>
<td class='wpsc_totals'>
<?php _e('Total Price:', 'wpsc'); ?>
</td>
<td class='wpsc_totals'>
<span id='checkout_total' class="pricedisplay checkout-total"><?php echo wpsc_cart_total(); ?></span>
</td>
</tr>
</table>
<form class='wpsc_checkout_forms' action='<?php echo esc_url( get_option( 'shopping_cart_url' ) ); ?>' method='post' enctype="multipart/form-data">
<?php
/**
* Both the registration forms and the checkout details forms must be in the same form element as they are submitted together, you cannot have two form elements submit together without the use of JavaScript.
*/
?>
<?php if(wpsc_show_user_login_form()):
global $current_user;
get_currentuserinfo(); ?>
<div class="wpsc_registration_form">
<fieldset class='wpsc_registration_form wpsc_right_registration'>
<h2><?php _e('Join up now', 'wpsc');?></h2>
<label><?php _e('Username:', 'wpsc'); ?></label>
<input type="text" name="log" id="log" value="" size="20"/><br/>
<label><?php _e('Password:', 'wpsc'); ?></label>
<input type="password" name="pwd" id="pwd" value="" size="20" /><br />
<label><?php _e('E-mail', 'wpsc'); ?>:</label>
<input type="text" name="user_email" id="user_email" value="" size="20" /><br />
<div class="wpsc_signup_text"><?php _e('Signing up is free and easy! please fill out your details your registration will happen automatically as you checkout. Don\'t forget to use your details to login with next time!', 'wpsc');?></div>
</fieldset>
</div>
<div class="clear"></div>
<?php endif; // closes user login form
$misc_error_messages = wpsc_get_customer_meta( 'checkout_misc_error_messages' );
if( ! empty( $misc_error_messages ) ): ?>
<div class='login_error'>
<?php foreach( $misc_error_messages as $user_error ){?>
<p class='validation-error'><?php echo $user_error; ?></p>
<?php } ?>
</div>
<?php
endif;
?>
<?php ob_start(); ?>
<table class='wpsc_checkout_table table-1'>
<?php $i = 0;
while (wpsc_have_checkout_items()) : wpsc_the_checkout_item(); ?>
<?php if(wpsc_checkout_form_is_header() == true){
$i++;
//display headers for form fields ?>
<?php if($i > 1):?>
</table>
<table class='wpsc_checkout_table table-<?php echo $i; ?>'>
<?php endif; ?>
<tr <?php echo wpsc_the_checkout_item_error_class();?>>
<td <?php wpsc_the_checkout_details_class(); ?> colspan='2'>
<h4><font color="#1956cf"><?php echo wpsc_checkout_form_name();?></h4>
</td>
</tr>
<?php if(wpsc_is_shipping_details()):?>
<tr class='same_as_shipping_row'>
<td colspan ='2'>
<?php $checked = '';
$shipping_same_as_billing = wpsc_get_customer_meta( 'shipping_same_as_billing' );
if(isset($_POST['shippingSameBilling']) && $_POST['shippingSameBilling'])
$shipping_same_as_billing = true;
elseif(isset($_POST['submit']) && !isset($_POST['shippingSameBilling']))
$shipping_same_as_billing = false;
wpsc_update_customer_meta( 'shipping_same_as_billing', $shipping_same_as_billing );
if( $shipping_same_as_billing )
$checked = 'checked="checked"';
?>
<label for='shippingSameBilling'><?php _e('Same as billing address:','wpsc'); ?></label>
<input type='checkbox' value='true' name='shippingSameBilling' id='shippingSameBilling' <?php echo $checked; ?> />
<br/><span id="shippingsameasbillingmessage"><?php _e('Your order will be shipped to the billing address', 'wpsc'); ?></span>
</td>
</tr>
<?php endif;
// Not a header so start display form fields
}elseif(wpsc_disregard_shipping_state_fields()){
?>
<tr class='wpsc_hidden'>
<td class='<?php echo wpsc_checkout_form_element_id(); ?>'>
<label for='<?php echo wpsc_checkout_form_element_id(); ?>'>
<?php echo wpsc_checkout_form_name();?>
</label>
</td>
<td>
<?php echo wpsc_checkout_form_field();?>
<?php if(wpsc_the_checkout_item_error() != ''): ?>
<p class='validation-error'><?php echo wpsc_the_checkout_item_error(); ?></p>
<?php endif; ?>
</td>
</tr>
<?php
}elseif(wpsc_disregard_billing_state_fields()){
?>
<tr class='wpsc_hidden'>
<td class='<?php echo wpsc_checkout_form_element_id(); ?>'>
<label for='<?php echo wpsc_checkout_form_element_id(); ?>'>
<?php echo wpsc_checkout_form_name();?>
</label>
</td>
<td>
<?php echo wpsc_checkout_form_field();?>
<?php if(wpsc_the_checkout_item_error() != ''): ?>
<p class='validation-error'><?php echo wpsc_the_checkout_item_error(); ?></p>
<?php endif; ?>
</td>
</tr>
<?php
}elseif( $wpsc_checkout->checkout_item->unique_name == 'billingemail'){ ?>
<?php $email_markup =
"<div class='wpsc_email_address'>
<p class='" . wpsc_checkout_form_element_id() . "'>
<label class='wpsc_email_address' for='" . wpsc_checkout_form_element_id() . "'>
" . __('Enter your email address', 'wpsc') . "
</label>
<p class='wpsc_email_address_p'>
<img src='https://secure.gravatar.com/avatar/empty?s=60&d=mm' id='wpsc_checkout_gravatar' />
" . wpsc_checkout_form_field();
if(wpsc_the_checkout_item_error() != '')
$email_markup .= "<p class='validation-error'>" . wpsc_the_checkout_item_error() . "</p>";
$email_markup .= "</div>";
}else{ ?>
<tr>
<td class='<?php echo wpsc_checkout_form_element_id(); ?>'>
<label for='<?php echo wpsc_checkout_form_element_id(); ?>'>
<?php echo wpsc_checkout_form_name();?>
</label>
</td>
<td>
<?php echo wpsc_checkout_form_field();?>
<?php if(wpsc_the_checkout_item_error() != ''): ?>
<p class='validation-error'><?php echo wpsc_the_checkout_item_error(); ?></p>
<?php endif; ?>
</td>
</tr>
<?php }//endif; ?>
<?php endwhile; ?>
<?php
$buffer_contents = ob_get_contents();
ob_end_clean();
if(isset($email_markup))
echo $email_markup;
echo $buffer_contents;
?>
<?php if (wpsc_show_find_us()) : ?>
<tr>
<td><label for='how_find_us'><?php _e('How did you find us' , 'wpsc'); ?></label></td>
<td>
<select name='how_find_us'>
<option value='Word of Mouth'><?php _e('Word of mouth' , 'wpsc'); ?></option>
<option value='Advertisement'><?php _e('Advertising' , 'wpsc'); ?></option>
<option value='Internet'><?php _e('Internet' , 'wpsc'); ?></option>
<option value='Customer'><?php _e('Existing Customer' , 'wpsc'); ?></option>
</select>
</td>
</tr>
<?php endif; ?>
<?php do_action('wpsc_inside_shopping_cart'); ?>
<?php //this HTML displays activated payment gateways ?>
<?php if(wpsc_gateway_count() > 1): // if we have more than one gateway enabled, offer the user a choice ?>
<tr>
<td colspan='2' class='wpsc_gateway_container'>
<h3><font color="#1956cf"><?php _e('Payment Type', 'wpsc');?></font></h3>
<?php while (wpsc_have_gateways()) : wpsc_the_gateway(); ?>
<div class="custom_gateway">
<label><input type="radio" value="<?php echo wpsc_gateway_internal_name();?>" <?php echo wpsc_gateway_is_checked(); ?> name="custom_gateway" class="custom_gateway"/><?php echo wpsc_gateway_name(); ?>
<?php if( wpsc_show_gateway_image() ): ?>
<img src="<?php echo wpsc_gateway_image_url(); ?>" alt="<?php echo wpsc_gateway_name(); ?>" style="position:relative; top:5px;" />
<?php endif; ?>
</label>
答案 0 :(得分:0)
未经测试:
<?php // This is used to fix the hook being called twice incorrectly ?>
<?php global $receivedItemHooks ?>
<?php if (!$receivedItemHooks) $receivedItemHooks = array() ?>
<?php if (!isset($receivedItemHooks[wpsc_the_cart_item_key()]): ?>
<!-- Your HTML goes here -->
<?php // Mark the item as rendered ?>
<?php $receivedItemHooks[wpsc_the_cart_item_key()] = true ?>
<?php endif ?>
这取决于函数wpsc_the_cart_item_key()
为每个购物篮项目返回一个唯一的参考(不是产品代码,因为如果将产品作为两个单独的商品而不是一个商品添加到购物篮中,那么这将不是唯一的数量为2)。
这应该是一个好的开始,但不要害怕修改和调试!
答案 1 :(得分:0)
我遇到了类似的问题,其中wordpres不断向数据库添加两次并通过电子邮件发送两次,在几周之后无法找到解决方案之后,我终于发现了一些与不正确的html有关的问题,它最终证明是表格围绕着这个问题的PHP,我不知道为什么但是一旦我用div替换了表它完全没问题。虽然我检查了表格,但它似乎是正确构造的,我猜它可能是由于表格而出现的某种wordpress缺陷。我知道它没有意义,但在我的情况下它是解决方案所以我强烈建议你用div替换表格,希望这对你有用。祝你好运,希望能解决你的问题。
答案 2 :(得分:0)
你可以通过会议来解决这个问题
<?php
add_action('init','my');
function my()
{
session_start();
if( ! isset( $_SESSION['okay'] ) )
{
$obj = new Hasan;
$obj->title = "we will we will rock you";
$obj->save();
$_SESSION['okay'] = 'okay';
}
else
{
unset($_SESSION['okay']);
}
}