質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
WordPress

WordPressは、PHPで開発されているオープンソースのブログソフトウェアです。データベース管理システムにはMySQLを用いています。フリーのブログソフトウェアの中では最も人気が高く、PHPとHTMLを使って簡単にテンプレートをカスタマイズすることができます。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

Q&A

解決済

1回答

2023閲覧

do処理の先頭に不要な要素が入る

wilsher

総合スコア15

WordPress

WordPressは、PHPで開発されているオープンソースのブログソフトウェアです。データベース管理システムにはMySQLを用いています。フリーのブログソフトウェアの中では最も人気が高く、PHPとHTMLを使って簡単にテンプレートをカスタマイズすることができます。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

0グッド

0クリップ

投稿2016/11/08 02:42

編集2016/11/08 04:09

下記コードを実行すると、添付画像のように、フォームの先頭に空白の行が出来てしまいます。
wordpressのwelcartプラグインを使っています。
原因は、何でしょうか?

イメージ説明言語を入力

<?php /** * <meta content="charset=UTF-8"> * @package Welcart * @subpackage Welcart Default Theme */ get_header(); ?> <div id="content" class=""> <div class="catbox"> <?php if (have_posts()) : the_post(); ?> <div <?php post_class() ?> id="post-<?php the_ID(); ?>"> <h1 class="item_page_title"><?php the_title(); ?></h1> <div class="storycontent"> <?php usces_remove_filter(); ?> <?php usces_the_item(); ?> <div id="itempage"> <div id="first-view"> <div id="first-view-left"> <div class="itemimg"> <a href="<?php usces_the_itemImageURL(0); ?>" <?php echo apply_filters('usces_itemimg_anchor_rel', NULL); ?>><?php usces_the_itemImage(0, 300, 300, $post); ?></a> </div> <div class="itemsubimg"> <?php $imageid = usces_get_itemSubImageNums(); ?> <?php foreach ( $imageid as $id ) : $thumb_post = get_post($imageid); $caption = $thumb_post->post_excerpt; ?> <div class="caption"> <?php echo $caption; ?> </div> <a href="<?php usces_the_itemImageURL($id); ?>" <?php echo apply_filters('usces_itemimg_anchor_rel', NULL); ?>> <?php usces_the_itemImage($id, 135, 135, $post); ?> </a> <?php endforeach; ?> </div><!-- end of itemsubimg --> </div><!-- end of first-view-left --> <div id="cart"> <form action="<?php echo USCES_CART_URL; ?>" method="post"> <div class="skuWrap"> <?php do { ?> <div class="skuBox flex"> <div class="skuName"><?php usces_the_itemSkuDisp(); ?></div> <?php if (usces_is_options()) : ?> <div><?php _e('Please appoint an option.', 'usces'); ?></div> <?php while (usces_have_options()) : ?> <div><?php usces_the_itemOptName(); ?></div> <div><?php usces_the_itemOption(usces_getItemOptName(),''); ?></div> <?php endwhile; ?> <?php endif; ?> <div class="priceWrap"> <?php if( usces_the_itemCprice('return') > 0 ) : ?> <s class="cprice"><?php usces_the_itemCpriceCr(); ?></s> <?php endif; ?> <div class="price"><?php usces_the_itemPriceCr(); ?></div> </div> <?php usces_the_itemGpExp(); ?> <div class="zaiko"><?php usces_the_itemZaikoStatus(); ?></div> <div class="quant"><?php usces_the_itemQuant(); ?></div> <div class="unit"><?php usces_the_itemSkuUnit(); ?></div> <?php if( !usces_have_zaiko() ) : ?> <div class="button"><?php echo apply_filters('usces_filters_multi_sku_zaiko_message', esc_html(usces_get_itemZaiko( 'name' ))); ?></div> <?php else : ?> <div class="button"><?php usces_the_itemSkuButton(__('Add to Shopping Cart', 'usces'), 0); ?></div> <?php endif; ?> <div colspan="5" class="error_message"><?php usces_singleitem_error_message($post->ID, usces_the_itemSku('return')); ?></div> </div><!--//skuwrap--> <?php } while (usces_have_skus()); ?> </div> <?php echo apply_filters('single_item_multi_sku_after_field', NULL); ?> <?php do_action('usces_action_single_item_inform'); ?> </form> </div><!-- end of cart --> </div><!-- end of first-view --> <?php if(usces_sku_num() === 1) : usces_have_skus(); ?> <!--1SKU--> <h2 class="item_name"><?php usces_the_itemName(); ?> (<?php usces_the_itemCode(); ?>)</h2> <div class="exp clearfix"> <div class="field"> <?php if( usces_the_itemCprice('return') > 0 ) : ?> <div class="field_name"><?php _e('List price', 'usces'); ?><?php usces_guid_tax(); ?></div> <div class="field_cprice"><?php usces_the_itemCpriceCr(); ?></div> <?php endif; ?> <div class="field_name"><?php _e('selling price', 'usces'); ?><?php usces_guid_tax(); ?></div> <div class="field_price"><?php usces_the_itemPriceCr(); ?></div> </div> <div class="field"><?php _e('stock status', 'usces'); ?> : <?php usces_the_itemZaikoStatus(); ?></div> <?php if( $item_custom = usces_get_item_custom( $post->ID, 'list', 'return' ) ) : ?> <div class="field"><?php echo $item_custom; ?></div> <?php endif; ?> <?php the_content(); ?> </div><!-- end of exp --> <form action="<?php echo USCES_CART_URL; ?>" method="post"> <?php usces_the_itemGpExp(); ?> <div class="skuform" align="right"> <?php if (usces_is_options()) : ?> <table class='item_option'> <caption><?php _e('Please appoint an option.', 'usces'); ?></caption> <?php while (usces_have_options()) : ?> <tr><th><?php usces_the_itemOptName(); ?></th><td><?php usces_the_itemOption(usces_getItemOptName(),''); ?></td></tr> <?php endwhile; ?> </table> <?php endif; ?> <?php if( !usces_have_zaiko() ) : ?> <div class="zaiko_status"><?php echo apply_filters('usces_filters_single_sku_zaiko_message', esc_html(usces_get_itemZaiko( 'name' ))); ?></div> <?php else : ?> <div style="margin-top:10px"><?php _e('Quantity', 'usces'); ?><?php usces_the_itemQuant(); ?><?php usces_the_itemSkuUnit(); ?><?php usces_the_itemSkuButton(__('Add to Shopping Cart', 'usces'), 0); ?></div> <div class="error_message"><?php usces_singleitem_error_message($post->ID, usces_the_itemSku('return')); ?></div> <?php endif; ?> </div><!-- end of skuform --> <?php echo apply_filters('single_item_single_sku_after_field', NULL); ?> <?php do_action('usces_action_single_item_inform'); ?> </form> <?php do_action('usces_action_single_item_outform'); ?> <?php elseif(usces_sku_num() > 1) : usces_have_skus(); ?> <!--some SKU--> <!--<h2 class="item_name SOMESKU"><?php usces_the_itemName(); ?> (<?php usces_the_itemCode(); ?>)</h2>--> <div class="exp clearfix"> <?php the_content(); ?> <?php if( $item_custom = usces_get_item_custom( $post->ID, 'list', 'return' ) ) : ?> <div class="field"> <?php echo $item_custom; ?> </div> <?php endif; ?> </div><!-- end of exp --> <form action="<?php echo USCES_CART_URL; ?>" method="post"> <div class="skuWrap"> <?php do { ?> <div class="skuBox flex"> <div class="skuName"><?php usces_the_itemSkuDisp(); ?></div> <?php if (usces_is_options()) : ?> <div><?php _e('Please appoint an option.', 'usces'); ?></div> <?php while (usces_have_options()) : ?> <div><?php usces_the_itemOptName(); ?></div> <div><?php usces_the_itemOption(usces_getItemOptName(),''); ?></div> <?php endwhile; ?> <?php endif; ?> <div class="priceWrap"> <?php if( usces_the_itemCprice('return') > 0 ) : ?> <s class="cprice"><?php usces_the_itemCpriceCr(); ?></s> <?php endif; ?> <div class="price"><?php usces_the_itemPriceCr(); ?></div> </div> <?php usces_the_itemGpExp(); ?> <div class="zaiko"><?php usces_the_itemZaikoStatus(); ?></div> <div class="quant"><?php usces_the_itemQuant(); ?></div> <div class="unit"><?php usces_the_itemSkuUnit(); ?></div> <?php if( !usces_have_zaiko() ) : ?> <div class="button"><?php echo apply_filters('usces_filters_multi_sku_zaiko_message', esc_html(usces_get_itemZaiko( 'name' ))); ?></div> <?php else : ?> <div class="button"><?php usces_the_itemSkuButton(__('Add to Shopping Cart', 'usces'), 0); ?></div> <?php endif; ?> <div colspan="5" class="error_message"><?php usces_singleitem_error_message($post->ID, usces_the_itemSku('return')); ?></div> </div><!--//skuwrap--> <?php } while (usces_have_skus()); ?> </div> <?php echo apply_filters('single_item_multi_sku_after_field', NULL); ?> <?php do_action('usces_action_single_item_inform'); ?> </form> <?php do_action('usces_action_single_item_outform'); ?> <?php endif; ?> </div><!-- end of itemspage --> </div><!-- end of storycontent --> </div> <?php else: ?> <p><?php _e('Sorry, no posts matched your criteria.'); ?></p> <?php endif; ?> </div><!-- end of catbox --> </div><!-- end of content --> <?php get_footer(); ?>

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

kei344

2016/11/08 04:00

コードはそれぞれコードブロックで囲んでいただけませんか? ```(バッククオート3つ)で囲み、前後に改行をいれるか、コードを選択して「<code>」ボタンを押すとコードブロックになります。記入エリアの右部分あたりにリアルタイムに結果が表示されていると思うので、そこを見ながら調整してください。また、ifやwhileの対応が適切にインデントされているかもしくはどのifと対応するかを記述いただけませんか?
wilsher

2016/11/08 04:07

対応しました。
guest

回答1

0

ベストアンサー

welcartは使ったことがないですが…。
マニュアルを参照した感じでは、SKU情報をセットしてポインタを送りますとあるので、47行目のループに入る前にusces_have_skus()を呼び出す必要があるのだと思います。
マニュアル

投稿2016/11/09 05:05

ttyp03

総合スコア16996

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

wilsher

2016/11/09 05:09

ありがとうございます。 具体的には、どうのように記述すれば良いですか?
ttyp03

2016/11/09 05:16

いや、まあそのまんまですけど…。 <div class="skuWrap"> <?php usces_have_skus(); ?> ←この行を追加 <?php do { ?> ただこれだと0件の場合にも一周してしまうので、件数を取得して0件のときはループしないようにさせるか、doループではなく、whileループにしたほうがいいかもしれません。 whileの場合は以下のような感じでしょうか。 <div class="skuWrap"> <?php while(usces_have_skus()){ ?> ~ <?php } ?>
wilsher

2016/11/21 02:40

ありがとうございます。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問