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

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

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

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

プラグイン

プラグイン(plug-in)は、ソフトウェアアプリケーションの機能拡張の為に開発された、一組のソフトウェアコンポーネントのことを指します。

JavaScript

JavaScriptは、プログラミング言語のひとつです。ネットスケープコミュニケーションズで開発されました。 開発当初はLiveScriptと呼ばれていましたが、業務提携していたサン・マイクロシステムズが開発したJavaが脚光を浴びていたことから、JavaScriptと改名されました。 動きのあるWebページを作ることを目的に開発されたもので、主要なWebブラウザのほとんどに搭載されています。

jQuery

jQueryは、JavaScriptライブラリのひとつです。 簡単な記述で、JavaScriptコードを実行できるように設計されています。 2006年1月に、ジョン・レシグが発表しました。 jQueryは独特の記述法を用いており、機能のほとんどは「$関数」や「jQueryオブジェクト」のメソッドとして定義されています。

Q&A

0回答

1160閲覧

wordpressのプラグインカスタマイズ、AmazonのASIN取得し個別詳細ページを作成

Aru.

総合スコア61

WordPress

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

プラグイン

プラグイン(plug-in)は、ソフトウェアアプリケーションの機能拡張の為に開発された、一組のソフトウェアコンポーネントのことを指します。

JavaScript

JavaScriptは、プログラミング言語のひとつです。ネットスケープコミュニケーションズで開発されました。 開発当初はLiveScriptと呼ばれていましたが、業務提携していたサン・マイクロシステムズが開発したJavaが脚光を浴びていたことから、JavaScriptと改名されました。 動きのあるWebページを作ることを目的に開発されたもので、主要なWebブラウザのほとんどに搭載されています。

jQuery

jQueryは、JavaScriptライブラリのひとつです。 簡単な記述で、JavaScriptコードを実行できるように設計されています。 2006年1月に、ジョン・レシグが発表しました。 jQueryは独特の記述法を用いており、機能のほとんどは「$関数」や「jQueryオブジェクト」のメソッドとして定義されています。

0グッド

0クリップ

投稿2019/01/04 14:02

wordpressのプラグインSearchAzonをカスタマイズしたいです。
一覧の商品をクリックしたらその商品のASIN番号を取得し(js1)、
別のファイルのプログラムで商品詳細ページを動的に生成、
自分のサイトで購入するようにしたい。

全然知識ないのでプログラムをそのまま載せます。(js1)
別のファイルのプログラムは文字数の関係でこの質問ページにできないため
新規で質問します

可能でしょうか?

js1

1 2 3// Initialization and events code for the app 4WooZonePNF_frontend = (function ($) { 5 "use strict"; 6 7 var maincontainer = null, response_elm = null, paged = 1, per_page = 10, placeholder = ''; 8 9 // init function, autoload 10 (function init() { 11 12 // load the triggers 13 $(document).ready(function(){ 14 maincontainer = $(".WooZonePNF-amazon-products"); 15 var wrapper = $(".WooZonePNF-amazon-products-wrapper"); 16 17 var where = maincontainer.data('where'); 18 var current_case = null; 19 20 // woocommerce case 21 if( wrapper.size() == 1 ){ 22 current_case = 'woocommerce'; 23 maincontainer.detach().appendTo( $(".WooZonePNF-amazon-products-wrapper") ); 24 } 25 26 // custom case, if is kingdom 27 else if( $("#kingdom-main-style-css").size() > 0 ){ 28 // detect if current page is product search results 29 //archive search search-no-results post-type-archive-product 30 31 if( $("body.archive.search.search-no-results.post-type-archive-product").size() > 0 ){ 32 current_case = 'woocommerce'; 33 maincontainer.detach().appendTo( $('.kd_archive_pg') ); 34 maincontainer.show(); 35 }else{ 36 if( $("body.search.search-no-results").size() > 0 ){ 37 current_case = 'blog'; 38 maincontainer.detach().appendTo( $('.main-content-box') ); 39 maincontainer.show(); 40 } 41 } 42 } 43 44 else{ 45 current_case = 'blog'; 46 // try to write the wrapper based on get_search_form 47 var valid_wrapper = null; 48 $("form[role='search']").each( function(){ 49 var __that = $(this); 50 if( !__that.parent().hasClass('widget') ){ 51 valid_wrapper = __that; 52 } 53 }); 54 55 if( valid_wrapper.parents('.site-main').eq(0).size() > 0 ){ 56 valid_wrapper = valid_wrapper.parents('.site-main').eq(0); 57 } 58 59 if( valid_wrapper.parents('.inner-content').eq(0).size() > 0 ){ 60 valid_wrapper = valid_wrapper.parents('.inner-content').eq(0); 61 } 62 63 valid_wrapper.append("<div class='WooZonePNF-amazon-products-wrapper'></div>"); 64 valid_wrapper = valid_wrapper.find('.WooZonePNF-amazon-products-wrapper'); 65 valid_wrapper.each(function(){ 66 maincontainer.detach().appendTo( $(this)); 67 }) 68 } 69 70 if( where != "both" ){ 71 if( current_case == 'blog' && where != 'blog' ){ 72 maincontainer.remove(); 73 return true; 74 } 75 76 if( current_case == 'woocommerce' && where != 'woocommerce' ){ 77 maincontainer.remove(); 78 return true; 79 } 80 } 81 82 console.log(current_case, where ); 83 84 response_elm = maincontainer.find(".WooZonePNF-amazon-response"); 85 86 per_page = maincontainer.data('perpage'); 87 placeholder = maincontainer.data('placeholder'); 88 89 save_statistics({ 90 'action' : 'new_search', 91 'keyword' : maincontainer.data('keyword'), 92 'url' : window.location.href, 93 'country' : maincontainer.data('country'), 94 'amzsite' : maincontainer.data('amzsite') 95 }); 96 97 triggers(); 98 }); 99 })(); 100 101 var Pagination = { 102 103 code: '', 104 105 // converting initialize data 106 Extend: function(data) { 107 data = data || {}; 108 Pagination.size = data.size || 300; 109 Pagination.page = data.page || 1; 110 Pagination.step = data.step || 3; 111 }, 112 113 // add pages by number (from [s] to [f]) 114 Add: function(s, f) { 115 for (var i = s; i < f; i++) { 116 Pagination.code += '<a>' + i + '</a>'; 117 } 118 }, 119 120 // add last page with separator 121 Last: function() { 122 Pagination.code += '<i>...</i><a>' + Pagination.size + '</a>'; 123 }, 124 125 126中略 127 128 129 130 html.push( '<div class="WooZonePNF-product" data-asin="' + ( product.ASIN ) + '">' ); 131 if( product.IsPrimeEligible > 0 ){ 132 html.push( '<div class="WooZonePNF-is-prime"></div>' ); 133 } 134 135 var buyurl = maincontainer.data('buyurl').replace( "{ASIN}", product.ASIN ); 136 html.push( '<div class="WooZonePNF-image"><a href="' + ( buyurl ) + '" target="_blank" class="WooZonePNF-monitor-redirect"><img src="' + ( product.ImageUrl ) + '" /></a></div>' ); 137 138 //category 139 if( typeof(product.category) != "undefined" ){ 140 html.push( '<div class="WooZonePNF-subtitle">' + ( product.category ) + '</div>' ); 141 }else{ 142 html.push( '<div class="WooZonePNF-subtitle">' + ( product.Subtitle ) + '</div>' ); 143 } 144 145 html.push( '<div class="WooZonePNF-title">' + ( product.Title ) + '</div>' ); 146 if( product.Rating != "" ){ 147 html.push( '<div class="WooZonePNF-rating" data-rating="' + ( product.Rating ) + '"></div>' ); 148 html.push( '<a href="#" class="WooZonePNF-rating-totals">(' + ( product.TotalReviews ) + ')</a>' ); 149 } 150 html.push( '<div class="WooZonePNF-price">' ); 151 152 if( typeof(product.ListPrice) != "undefined" ){ 153 html.push( '<div class="WooZonePNF-old-price">' + ( product.ListPrice ) + '</div>' ); 154 } 155 if( typeof(product.Price) != "undefined" ){ 156 html.push( '<div class="WooZonePNF-new-price">' + ( product.Price ) + '</div>' ); 157 } 158 html.push( '</div>' ); 159 html.push( '<a href="' + ( buyurl ) + '" target="_blank" class="WooZonePNF-button WooZonePNF-monitor-redirect">' + ( maincontainer.data('btntext') ) + '</a>' ); 160 html.push( '</div>' ); 161 162 return html.join("\n"); 163 } 164 165 function search_callback( data ) 166 { 167 var total_results = data['NumRecords'], 168 results = data['results'], 169 html = []; 170 171 if( total_results > 0 && results.length > 0 ){ 172 173 //maincontainer.find('.WooZonePNF-number-results-found').show(); 174 175 /*if( maincontainer.find('.WooZonePNF-number-results-found').html() == '' ) { 176 maincontainer.find('.WooZonePNF-number-results-found').html( WooZonePNF_custom.translation.nb_results.replace('{nb_results}', total_results) ); 177 }*/ 178 179 maincontainer.find('.WooZonePNF_next_page').show(); 180 181 $.each( results, function(key, value){ 182 html.push( build_product_box( value ) ); 183 }); 184 185 response_elm.html( html.join("\n") ); 186 187 build_rating(); 188 189 if( maincontainer.data('showpagination') == 'yes' && total_results > per_page ){ 190 build_pagination( total_results ); 191 } 192 } 193 194 // debug ... 195 console.log( total_results, results ); 196 } 197 198 function save_statistics( params ) 199 { 200 $.post( 201 WooZonePNF_custom.ajaxurl, { 202 'action': 'WooZonePNF_save_stats', 203 'params': params 204 205 }, function(response) { 206 } 207 ); 208 } 209 210 function add_new_click( that ) 211 { 212 var parent = that.parents('.WooZonePNF-product').eq(0), 213 asin = parent.data('asin'); 214 215 save_statistics({ 216 'action' : 'click', 217 'url' : that.attr('href'), 218 'keyword' : maincontainer.data('keyword'), 219 'country' : maincontainer.data('country'), 220 'amzsite' : maincontainer.data('amzsite') 221 }); 222 } 223 224 function triggers() 225 { 226 maincontainer.each(function(){ 227 get_products( $(this) ); 228 }); 229 230 $('body').on('mousedown', '.WooZonePNF-monitor-redirect', function(){ 231 add_new_click( $(this) ); 232 }); 233 } 234 235 return { 236 "search_callback": search_callback 237 } 238 239})(jQuery); 240 241function search_callback( data ){ 242 WooZonePNF_frontend.search_callback( data ); 243} 244



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

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

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

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

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

kei344

2019/01/04 14:03

「新規で質問」はやめてください。プラグインファイルを改変していないなら公式ディレクトリへのリンクで事足りるはずです。
Aru.

2019/01/04 14:17

有料プラグインです。
退会済みユーザー

退会済みユーザー

2019/01/05 02:44

WordPressのプラグインをカスタマイズするにはWordPressとPHPに関する知識が必要です。 「全然知識ない」のであれば、勉強をするか、勉強したくないのであれば詳しい人に依頼することをおすすめします。 少なくとも、teratailは「問題・課題に対する解決法」を求める場であり、自分ではできないことを依頼して丸投げする場ではありません。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問