会員情報ページのカスタマイズ

フォーラム 使い方全般 会員情報ページのカスタマイズ

  • このトピックには7件の返信、3人の参加者があり、最後にyskysmrにより9年、 5ヶ月前に更新されました。
8件の投稿を表示中 - 1 - 8件目 (全8件中)
  • 投稿者
    投稿
  • #72635
    JunichiK
    参加者

    いつもお世話になります。

    会員情報ページで、
    <?php usces_member_history(); ?>
    で出力される、購入履歴の表示項目等のカスタマイズ(表示・非表示・項目名変更等)をしたいのですが、表全体を変更するフックはございますか?
    カートページや内容確認ページはそれぞれ、usces_filter_cart_rows、usces_filter_confirm_rowsをテーマのfunctions.phpで書き換えてカスタマイズできたので、会員情報ページも同様にusces_filter_history_cart_rowsで可能なのかと思いましたが、変更できません。
    会員情報ページにはこのようなフックは用意されていないのでしょうか?

    何卒よろしくお願いいたします。

    #72653
    nanbu
    キーマスター

    こんにちは。

    フィルターフック ‘usces_filter_history_cart_row’ でカスタマイズ可能です。

    #72681
    JunichiK
    参加者

    nanbu様、ご返信ありがとうございます。

    ご教示いただいたフックで、テーマのfunctions.phpに下記のように書いて、不要な数量の削除を試みたのですが、変更が反映されません。
    どこが間違っているのでしょうか?

    add_filter( 'usces_filter_history_cart_row', 'my_filter_history_cart_row' );
    function my_filter_history_cart_row( $html ) {
    	for($i=0; $i<count($cart); $i++) { 
    		$cart_row = $cart[$i];
    		$ordercart_id = $cart_row['cart_id'];
    		$post_id = $cart_row['post_id'];
    		$sku = urldecode($cart_row['sku']);
    		$quantity = $cart_row['quantity'];
    		$options = $cart_row['options'];
    		$itemCode = $usces->getItemCode($post_id);
    		$itemName = $usces->getItemName($post_id);
    		$cartItemName = $usces->getCartItemName($post_id, $sku);
    		$skuPrice = $cart_row['price'];
    		$pictid = (int)$usces->get_mainpictid($itemCode);
    		$optstr =  '';
    		if( is_array($options) && count($options) > 0 ){
    			$optstr = '';
    			foreach($options as $key => $value){
    				if( !empty($key) ) {
    					$key = urldecode($key);
    					$value = maybe_unserialize($value);
    					if(is_array($value)) {
    						$c = '';
    						$optstr .= esc_html($key) . ' : '; 
    						foreach($value as $v) {
    							$optstr .= $c.nl2br(esc_html(urldecode($v)));
    							$c = ', ';
    						}
    						$optstr .= "<br />\n"; 
    					} else {
    						$optstr .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n"; 
    					}
    				}
    			}
    			$optstr = apply_filters( 'usces_filter_option_history', $optstr, $options);
    		}
    		$optstr = apply_filters( 'usces_filter_option_info_history', $optstr, $umhs, $cart_row, $i );
    			
    		$history_cart_row = '<tr>
    			<td>' . ($i + 1) . '</td>
    			<td>';
    		$cart_thumbnail = '<a href="' . get_permalink($post_id) . '">' . wp_get_attachment_image( $pictid, array(60, 60), true ) . '</a>';
    		$history_cart_row .= apply_filters('usces_filter_cart_thumbnail', $cart_thumbnail, $post_id, $pictid, $i, $cart_row);
    		$history_cart_row .= '</td>
    			<td class="aleft"><a href="' . get_permalink($post_id) . '">' . esc_html($cartItemName) . '<br />' . $optstr . '</a>' . apply_filters('usces_filter_history_item_name', NULL, $umhs, $cart_row, $i) . '</td>
    			<td class="rightnum">' . usces_crform($skuPrice * $cart_row['quantity'], true, false, 'return') . '</td>
    			</tr>';
    		$materials = compact( 'cart_thumbnail', 'post_id', 'pictid', 'cartItemName', 'optstr' );
    	}
    	return $html;
    }

    ご教示のほど何卒よろしくお願いいたします。

    #72719
    yskysmr
    キーマスター

    こんにちは。

    変更した内容が、$html に反映されていないのではないでしょうか。

    #72742
    JunichiK
    参加者

    yskysmr様、ありがとうございます。

    そうだとは思うのですが、私のスキル不足のため、なぜ反映しないのか分からないのです。
    テーマのfunctions.phpに書いた上記の内容に間違いや怪しいところはございますか?
    何かヒントだけでもいただければ幸いです。

    何卒よろしくお願いいたします。

    #72755
    yskysmr
    キーマスター

    このコードでは、$html; の内容を編集することなく、そのまま返却しています。

    #72760
    JunichiK
    参加者

    yskysmr様、ご返信ありがとうございます。

    当方のスキルが低いため、正直よく分かりません。
    試しに下記のようにしてみましたら、不要な列の削除は出来ましたが、表の内容が反映されませんでした。

    add_filter( 'usces_filter_history_cart_row', 'my_filter_history_cart_row', 10 ,5 );
    function my_filter_history_cart_row() {
    $args = func_get_args();
    list($history_cart_row, $umhs, $cart_row, $i, $materials) = $args;
    
    			$history_cart_row = '<tr>
    				<td>' . ($i + 1) . '</td>
    				<td>';
    			$cart_thumbnail = '<a href="' . get_permalink($post_id) . '">' . wp_get_attachment_image( $pictid, array(60, 60), true ) . '</a>';
    			$history_cart_row .= apply_filters('usces_filter_cart_thumbnail', $cart_thumbnail, $post_id, $pictid, $i, $cart_row);
    			$history_cart_row .= '</td>
    				<td class="aleft"><a href="' . get_permalink($post_id) . '">' . esc_html($cartItemName) . '<br />' . $optstr . '</a>' . apply_filters('usces_filter_history_item_name', NULL, $umhs, $cart_row, $i) . '</td>
    				<td class="rightnum">' . usces_crform($skuPrice * $cart_row['quantity'], true, false, 'return') . '</td>
    				</tr>';
    			$materials = compact( 'cart_thumbnail', 'post_id', 'pictid', 'cartItemName', 'optstr' );
    
    return $history_cart_row;
    }

    引数や変数の宣言を加えたりも試行錯誤してみましたが、うまくいきません。
    ご教示のほどよろしくお願いいたします。

    #72762
    yskysmr
    キーマスター

    試行錯誤を続けていただくしかございません。がんばってください。

8件の投稿を表示中 - 1 - 8件目 (全8件中)
  • このトピックに返信するにはログインが必要です。